Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ykarikos
Created May 28, 2012 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykarikos/2817865 to your computer and use it in GitHub Desktop.
Save ykarikos/2817865 to your computer and use it in GitHub Desktop.
Transpose utf-8 string columns as rows and vice versa
#!/usr/bin/python
#
# transpose.py (C) 2012 Yrjo Kari-Koskinen <ykk@peruna.fi>
#
# 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