-2

I want to write the csv (huge) data to excel file using python. I have read the csv file using csv.reader like-

with open(main_path+i_bu_name+"/"+str(snapshot_id)+"/"+input_folder+input_csv_name,'rb') as input:
                print "entering file read"
                reader=csv.reader(input)
                #datalist=list(reader)

Now i want to paste this reader to an existing excel file which has some formatting saved in it so i am using win32com python library to write csv reader data to excel. Whenever i try pandas to_excel() method, it removes the existing formatting from excel. Please help, how can i write this huge data to excel without removing formatting from excel.

anurag
  • 590
  • 3
  • 8
  • 27

1 Answers1

0

You should use Value property:

Worksheets("Sheet1").Range("A1:A5").Value = [1, 2, 3, 4, 5]
apr
  • 370
  • 1
  • 5
  • I am using Value property, but as i said my data is huge so there is always memory problem. – anurag Apr 06 '16 at 09:32
  • Please, add example code and error you get to the question. – apr Apr 06 '16 at 09:48
  • 1
    IMHO, fragmenting the data [e.g. based on this question](http://stackoverflow.com/questions/17444679/reading-a-huge-csv-in-python) and populating the excel file with the fragments' contents would do the trick. – Laur Ivan Apr 06 '16 at 10:28
  • reading the data was not the problem statement, problem is in writing it to xls file. – anurag Apr 06 '16 at 11:28