mardi 5 juillet 2016

Insert new column in CSV by looping through data


This is what I have (and it's a bit more of a thought experiment than actual code). I have a very large text document that was translated from XML for reasons beyond me. I am trying to write it into a CSV. What I have inherited is one long single column. I need to insert into the text document the evidentially secret combination of characters that will induce a new column.

For example the text looks like this, as does the csv. There are no headers.

1 3 5 7 11 13 17 19 23

into this:

1 13 3 17 5 19 7 23 11

I can use python (or sed) to insert said super secret combo at predetermined points, like after 11 and before 13 to produce the desired results. That's not a problem. I can insert newlines ('n') at will. What I cannot find is the equivalent of ('n') with no luck. I've tried ('cr') and it simply writes it into a cell. Any ideas before the name calling begins? Thanks, B


Aucun commentaire:

Enregistrer un commentaire