python - Pandas to_csv index=False not working -


i'm writing fixed-width file csv. because file large read @ once, i'm reading file in chunks of 100000 , appending csv. working fine, it's adding index rows despite having set index = false.

how can complete csv file without index?

infile = filename outfile = outfilename cols = [(0,10), (12,19), (22,29), (34,41), (44,52), (54,64), (72,80), (82,106), (116,144), (145,152), (161,169), (171,181)]  chunk in pd.read_fwf(path, colspecs = col_spec, index=false, chunksize=100000): chunk.to_csv(outfile,mode='a') 

thanks!

the to_csv method has header parameter, indicating if output header. in case, not want writes not first write.

so, this:

for i, chunk in enumerate(pd.read_fwf(...)):     first = == 0     chunk.to_csv(outfile, header=first, mode='a') 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -