-4

I am trying to copy a column from a csv file to a spreadsheet in an excel file. However, for some reason the values from csv files aren't getting copied in the spreadsheet. The program compiles without any errors and all the statements are getting executed properly. My code is as follows:

#!/home/utils/Python-2.7/bin/python2.7
import csv
import urllib
import xlwt
import xlrd
from xlutils.copy import copy
book = xlrd.open_workbook('template2.xls')
wb = copy(book) # a writable copy 
w_sheet = wb.get_sheet(0)
with open('results2.csv', 'rb') as f:
    reader = csv.reader(f, delimiter=',')
    next(reader, None)
    next(reader, None)
    next(reader, None)
    next(reader, None)
    i = 0
    for row in reader:
        w_sheet.write(i, 3, row[5])
        i += 1
user3262537
  • 127
  • 1
  • 1
  • 7

1 Answers1

0

Don't forget to save your file

wb.save('test.xls')
aiscy
  • 113
  • 2
  • 12