I'm extracting values from a file which is sometimes an xls and sometimes an xlsx file. An xls is easily read with xlrd, but xlrd nor any other Python library (as far as I could find) supports xlsx, so instead I'm using xlsx2csv to convert to csv and then reading values from that.
I'm new to Python and only have beginner's knowledge of other scripting languages.
I'd like to select values from a specific column of the csv file (and fill a list with them). This is where I'm getting confused. When I convert the CSV with
infile = path + "\\" + filename xlsx2csv(infile, open("data.csv", "w+"))
and open it manually in Excel, I can see the values I want in column 5 at row 23 and onwards (with columns up to 5 and rows up to 23 containing values I do not want).
But when I open the csv file within Python with
values = csv.reader(open('data.csv', 'rb'), delimiter=' ')
I'm getting a list of lists. Printing the values with
for row in values: print row
gives the following (edited) result:
I feel like I've already gone wrong at this point. Or should I go with this and then split up the lists and get the last value from each separate list except the empty ones? I hope someone can help me to an elegant solution.