I need to delete the first row of an Excel spreadsheet before reading and importing it in FME (column headers are in the second row).
I found this script to use at startup (from http://stackoverflow.com/questions/12311345/manipulating-excel-2007-files-using-python):
#First we need to access the module that lets us connect to Excel
import win32com.client
# Next we want to create a variable that represents Excel
app = win32com.client.Dispatch("Excel.Application")
# Lastly we will assume that the workbook is active and get the first sheet
wbk = app.ActiveWorkbook
sheet = wbk.Sheets(1)
# delete the first row in your active sheet
sheet.Rows(1).Delete()
I tried it, but I get an error message saying I don’t have the win32com module on my computer. (I do not want people to have to download anything to use my workspace.)
Reading further, I found that maybe I should use someting like that instead :
import os
app = FME_MacroValues 'SourceDataset_XLS_ADO']
wbk = app.ActiveWorkbook
sheet = wbk.Sheets(1)
sheet.Rows(1).Delete()
Something is still missing as I now get this message :
Python Exception <AttributeError>: 'str' object has no attribute 'ActiveWorkbook'
If you can provide any help ...
I am new both to FME and Python.