Home

Michael Smith

What PyTranspose does

PyTranspose is a Python script that "rotates" a delimited text file, so that the columns become rows (and vice-versa). It will run in any environment that has python installed without requiring compilation.

This is alpha software

This software is still a bit rough because it's in severe alpha. I expect it to become beta by October 2011. I can't guarantee that it will production-ready ever, but if enough people use it and give me feedback, then who knows?

Installing PyTranspose

To use transpose, you need a computer with Python 2.X installed. Mac and Linux should have this already installed.


  1. First, download the file pytranspose.zip from SourceForge.

  2. If you like, put the file transpose.py in your path. You can do this by either moving transpose.py to a directory on your path or adding the directory where transpose.py is located to your path. Otherwise skip to the next step.

  3. Change the permissions on transpose.py so that anyone may execute it. This can be done on the command line with chmod 755 transpose.py.


Unlike the aforementioned transpose utility, this will run without compiling first.

Using PyTranspose

Suppose you have a text file that looks like this:

$ cat test
Hello, my name is Michael.
Goodbye, I must be going.

If we wanted to transpose on the whitespace, we would type:

$ transpose.py -w test
Hello, Goodbye,
my I
name must
is be
Michael. going.

transpose.py --whitespace is equivalent to transpose.py -w

If we wanted to transpose on the comma, we would type:

$ transpose.py -d=,
Hello,Goodbye
my name is Michael., I must be going.

transpose.py --delimiter is equivalent to transpose.py -d

To get help, type:

$ transpose.py --help

Important Windows Note!

PyTranspose will automatically detect what operating system you are using, and if you are using windows it will automatically format your output file correctly. However, there may be occasions where you need to take windows input and output to a UNIX format, or vice-versa. You can do this using the dos2unix and unix2dos utilities:

$ transpose.py unix-input.txt | unix2dos > win-output.txt
$ transpose.py win-input.txt | dos2unix > unix-output.txt



Alternatively, you can use the --unix and --win flags:

$ transpose.py unix-input.txt --win -o=win-output.txt
$ transpose.py win-input.txt --unix -o=unix-output.txt



The -U flag (note: capitalized!) is equivalent to --unix; the -W flag (also note: capitalized!) is equivalent to --win.

Please use this software and please criticize me!

I encourage you to use this script and to tell me what you think, whether it sucks or rocks, and what you need me to fix or would like for me to change about it. I'm not kidding. I can't make this code work better, and grow as a programmer, without your feedback.