0

The goal here is to take the xslx that is loaded and replace certain columns with the lists created from the csv. I could use some direction as to the easiest method in doing this.

For example, I would like to take col_test from the csv and place the values in column1 of the xslx sheet starting in row 5. Can I do this using the same xlsx or will they need to be saved to a new xlsx like I am currently doing?

What I need help with as it stands is figuring out the syntax for the write function. I would like it to write from the first column of row 6 until the end of the list used. How would I do this?

import os
import glob
import pandas as pd

for csvfile in glob.glob(os.path.join('.', '*.csv')):
    df = pd.read_csv(csvfile)

col_test = df['Test #'].tolist()
col_retest = df['Retest #'].tolist()

from xlrd import open_workbook
from xlutils.copy import copy

rb = open_workbook("Excel FDT Master_01_update.xlsx")
wb = copy(rb)

s = wb.get_sheet(3)
s.write(6,0:17,0, col_test)
wb.save('didthiswork.xls')
geojasm
  • 121
  • 9
  • I know the data is on sheet 4 – geojasm Dec 06 '17 at 20:13
  • 1
    Possible duplicate of [Edit existing excel workbooks and sheets with xlrd and xlwt](https://stackoverflow.com/questions/26957831/edit-existing-excel-workbooks-and-sheets-with-xlrd-and-xlwt) – hansaplast Dec 06 '17 at 20:21
  • It would help is you added a short example of what the CSV files look like and before/after for what your `.xlsx` file should look like, e.g. 5 rows worth. – Martin Evans Dec 12 '17 at 16:35

0 Answers0