This script easily extract data from microsoft excel files using this wrapper class for xlrd. The class allows you to create a generator which returns excel data one row at a time as either a list or dictionary. This script is very useful for easily pulling in a variety of excel files without having to deal with COM calls or even needing to have windows.
Data is extracted by creating a iterator object which can be used to return data one row at a time. The default extraction method assumes that the worksheet is in tabular format with the first nonblank row containing variable names and all subsequent rows containing values. This method returns a dictionary which uses the variables names as keys for each piece of data in the row. Data can also be extracted with each row represented by a list.
Extracted data is represented fairly logically. By default dates are returned as strings in "yyyy/mm/dd" format or "yyyy/mm/dd hh:mm:ss", as appropriate. However, dates can be return as a tuple containing
(Year, Month, Day, Hour, Min, Second) which is appropriate for usage with mxDateTime or DateTime. Numbers are returned as either INT or FLOAT, whichever is needed to support the data. Text, booleans, and
error codes are also returned as appropriate representations.