0
Hardest problem of the world.
How to add 64 blank columns at the beginning of a CSV file? By python.
5 Answers
+ 2
Did you try to Google?
https://stackoverflow.com/questions/11070527/how-to-add-a-new-column-to-a-csv-file
+ 2
When you say "add 64 blank columns at the beginning of a CSV file", did you mean the 64 blank columns were meant as header line to be named later on, or did you mean to add the 64 blank columns to each lines in the file?
+ 1
To each line of the file.......
+ 1
Sourya Banerjee
I have an idea, but I haven't tried to implement it, yet still I think it's worth a shot.
Read the entire file raw into a `list`, let's say the `list` was named <content>, maybe by using readlines(). And then close the file.
Next prepare the 64 new column
new_columns = ', ' * 64
And then you iterate the list using range()
for row_id in range( len( content ) ):
content[ row_id ] = new_columns + content[ row_id ]
This will prepend <new_columns> to each element in the `list`.
Finally you open the file for writing mode (not append mode), and save the `list` into the file.
Give it a shot! hope it works! đ
0
Yes.... it's shared link is useless....it is adding the column at the end..........