An easy way
Open the Terminal application and navigate to the folder containing your .txt file. If you know how to use
cd, use that. If you don't then open Finder and click on the folder containing your file and press ⌥⌘C. This will copy the path to the folder to your clipboard. Then in Terminal type, (pasting the clipboard ⌘V where it says <paste_here>):
and run the following command, replacing <your_file_name> with the name of your file and <new_file_name> for the name you want to give the transposed output.
cat <your_file_name> | tr ',' '\n' > <new_file_name>
In case you aren't sure what's going on here:
cat takes one or more file names and outputs their contents
| takes the output of the thing on the left and sends it to the thing on the right
tr replaces any instances of the first character (
, in this case) and replaces it with the second character (
\n means a new line)
Learning how to use Terminal will help you solve these kinds of problems very easily. If you want to learn more about it, google "unix/linux shell scripting" and the language being used is "bash".
A better way
tr ',' '\n' < infile > outfile
I gave the first answer because I felt it was easier to understand for someone who is new to shell scripting. But we can optimize this command by using file redirection (command < filename) instead of cat. Cat is an external program, so we should get rid of it in the command if there is no reason to load it.
tr doesn't accept filename arguments but it does accept standard input. Here we redirect "infile" to standard input (
< infile) which is read by the command (
tr ',' '\n'), then we write the output to outfile (> outfile).
You can also write this as: \
< infile tr ',' '\n' > outfile
I prefer writing it this way because it follows the same order as the commands are executed:
| Command | Action |
| ------------- | ---------------------------------------------- |
< infile | redirect file named "infile" to standard input |
tr ',' '\n' | replace commas with newlines |
> outfile | write standard out to filename "outfile" |