Jan-02-2018, 10:02 PM
Hello Forum,
I'm using csv package to build a .csv file in Python v3.6.
What I'm doing is converting and combining several .bib files into one CSV, which like reading text files and then putting them all in one CSV format. The nature of the files that I'm dealing with does not allow me to know the full header of the CSV in advance. Each file might add one or more header item. Which means that as I'm reading the files, the header keeps updating.
The code that I wrote is using csv.writer.writerow() to build the "Body" of the CSV first. After the CSV body is completely built, I want to go back and write the header.
So the question is, after using csv.writer.writerow(), how to go back to the top of the CSV file and add new first row (the header)?
Thank you all,
I'm using csv package to build a .csv file in Python v3.6.
What I'm doing is converting and combining several .bib files into one CSV, which like reading text files and then putting them all in one CSV format. The nature of the files that I'm dealing with does not allow me to know the full header of the CSV in advance. Each file might add one or more header item. Which means that as I'm reading the files, the header keeps updating.
The code that I wrote is using csv.writer.writerow() to build the "Body" of the CSV first. After the CSV body is completely built, I want to go back and write the header.
So the question is, after using csv.writer.writerow(), how to go back to the top of the CSV file and add new first row (the header)?
Thank you all,