1

I have a large dataframe with ~450 columns. I need to export it to csv, and for that I use the next command:

df.to_csv('output.csv', sep='\t', header=False, index=False, na_rep='null')

The resulting file is missing several of the trailing columns. I tried to update pandas display options, but that didn't solve the problem:

pd.set_option('display.max_columns', None)
pd.set_option('display.max_colwidth', -1)
pd.set_option('display.width', None)

Any help is appreciated.


Background: I need to export data from one DB table to the other, adding one more column on the fly. I export data to csv, create a dataframe from it, add a column, and then need to export it to csv again to import into the resulting table.

NothisIm
  • 53
  • 1
  • 6

1 Answers1

1

As it turned out, the original data had a quotation mark somewhere. This answer to another question helped me sort it out. I resolved the problem with:

pd.read_csv(file_obj, sep='\t', quoting=csv.QUOTE_NONE)
NothisIm
  • 53
  • 1
  • 6