Created
May 28, 2012 07:32
-
-
Save ykarikos/2817865 to your computer and use it in GitHub Desktop.
Transpose utf-8 string columns as rows and vice versa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# transpose.py (C) 2012 Yrjo Kari-Koskinen <[email protected]> | |
# | |
# This program is licensed under Version 2 of the GPL. | |
# | |
# Transpose utf-8 string columns as rows and vice versa | |
# You might need to set PYTHONIOENCODING=utf_8 before calling transpose.py | |
import sys | |
lines = [] | |
for line in sys.stdin.readlines(): | |
lines.append(unicode(line, "utf-8")) | |
firstLine = lines[0] | |
i = 0 | |
while firstLine[i] != '\n': | |
translatedLine = u"" | |
for line in lines: | |
translatedLine = translatedLine + line[i] | |
print(translatedLine) | |
i = i + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment