Reputation: 154
i have to fill a xlsx file with content using xlsx writer.
I collect data with pandas from an existing xlsx file and create the dataset "dataset_dn_1" (all NaN will be filled with the string from 'empty' :
data = pd.read_excel(file, skiprows=2)
dataset_s1_dn = pd.DataFrame(data, columns=['dn'])
dataset_s1_dn['dn'] = dataset_s1_dn['dn'].fillna(empty)
that works fine. After this I write the column to a record and make a list out of it (I have to use a list because I don't want to override the whole content in the destination file because of formatting):
rec_1 = dataset_s1_dn.to_records(index=False)
list_1 = list(rec_1)
Works also good.
Now I want to write the column to the destination file with the following loop:
for row, line in enumerate(list_1):
for col, cell in enumerate(line):
worksheet1.write(row, col, cell)
That works, but i want to start writing at cell A4 not A1. I tried the following but get an error:
worksheet1.write('A4', row, col, cell)
worksheet1.write(0, 3, row, col, cell)
both not working.
The error message:
TypeError: _write_number() takes from 4 to 5 positional arguments but 6 were given
Upvotes: 0
Views: 158
Reputation: 41614
That works, but i want to start writing at cell A4 not A1.
Something like this should probably work:
for row, line in enumerate(list_1):
for col, cell in enumerate(line):
worksheet1.write(row + 3, col, cell)
Upvotes: 2