I have a separate tab file in which the first few lines are comments designated with '#'. I use the following code to pull the file without the comments ... The file looks something like:
#comentario
#comentario
#comentario
#comentario
#comentario
Header1 Header2 Header3
a b c
d e f
g h i
And then I use the code below to load it without the comments ...
import pandas as pd
file_in = pd.read_table('arquivo.tsv', comment='#')
In this way:
Header1 Header2 Header3
a b c
d e f
g h i
After that I make some changes in the Header1 column based on the information from another file, and rewrite the file file_in
:
file_in.to_csv('arquivo.csv', index=False, sep='\t')
The point here is that I would like the comments to come back as in the original, but the saved file starts with the Header and no longer with the comments!