0

I have dataframe with 1 Million rows, I want to export to 2 csv files - 500k each.

Below code I use to export to csv:

exportPath='C:\sunil_plus\dataset\Data2SQLImport\reults.csv'
header=['Country','Indicator','Measure','Unit','Frequency','Date','Value']
data.to_csv(exportPath,columns=header,sep=',',index=False))
James Z
  • 12,209
  • 10
  • 24
  • 44
Learnings
  • 2,780
  • 9
  • 35
  • 55
  • @EdChum, while exporting I want to write to multiple csv files as per total count mentioned. In this case I want to export 5L rows to 2 csv file – Learnings Jun 14 '17 at 10:17
  • The dupe shows how to slice a df into different chunks you need to take a slice of the df and then export – EdChum Jun 14 '17 at 10:18
  • @EdChum, thanks... working... – Learnings Jun 14 '17 at 10:34
  • @EdChum, if I have to split more than 3/or more dataframe then how to do that: if data.shape[0] > 500000: exportFile1 = data[:500000] exportFile2 = data[500000:] – Learnings Jun 14 '17 at 10:42
  • You can just divide the number of rows to n or more dfs, this is really simple arithmetic – EdChum Jun 14 '17 at 10:48
  • yes I got it, thanks exportFile1 = data[:500000] exportFile2 = data[500000:1000000] exportFile3 = data[1000000:] – Learnings Jun 14 '17 at 11:09

0 Answers0