Background:
I have an excel workbook containing metadata which spread across various worksheets. I need to take the relevant columns of data from the various worksheets and combine them into a single worksheet. With the following code I have been able to create a new worksheet and add data to it.
# Open workbook and assign worksheet
try:
wb = openpyxl.load_workbook(metadata)
shtEditionLNM = wb.worksheets[0] # Edition date & latest NM
shtChartsTitles = wb.worksheets[1] # Charts & Titles
shtDepthHeight = wb.worksheets[4] # Depth & heights
shtChartProj = wb.worksheets[7] # Chart Projection
except:
raise SystemExit(0)
new = wb.create_sheet()
new.title = "MT_CHARTS INFO"
new.sheet_properties.tabColor = "1072BA"
shtMeta = wb.get_sheet_by_name("MT_CHARTS INFO")
for row in shtChartsTitles.rows:
shtMeta.append([row[0].value, row[1].value, row[2].value, row[4].value])
for row in shtEditionLNM.rows:
shtMeta.append([row[3].value, row[4].value])
wb.save('OW - Quarterly Extract of Metadata for Raster Charts Dec 2015.xlsx')
This works without any errors and I can see the data saved to my new workbook. However when I run a second loop and append values they are appended to cell A3169 whereas I actually want them to populate from E1.
My question boils down to 'is there a way I can append to a new column instead of a new row?'
Thanks in advance!