Reading a csv file with Python27 from an Excel 16 csv file using: import csv with open("C:\Users\RJ\FG\Line\Line List.csv") as csv_input: reader = csv.DictReader(csv_input) for row in reader: print(row)
produces all the correct data, but the first column in the Excel file is 'RoutingFrom', but here it is the last.
{'RoutingTo': 'AMINE DRAIN ', 'Item': '1', 'LineSectTag': 'AD-12-1-011-0', 'LDTDocNo': 'M6D-1P12-00009', 'RoutingFrom': '1AM-12010-0 '}
When I open the csv file with a text editor: Item,RoutingFrom,RoutingTo,LDTDocNo,LineSectTag where it is the second column.
The test editor view was the original order the file had. I will be using this to add edges in Networkx so I reordered the columns in the spreadsheet so the 'from' and 'to' where the first two columns. Excel displays them as the first two columns, Pyhton reads them as the first and last, the text editor shows them as the second and third.
I then took the rearranged (from, to, item, ...) csv file and copied as text onto a new spreadsheet which is where all of the above comes from.
Any suggestions on how to get a consistently ordered dataset?
BTW, I am working with a small subset of the actual data which is 10 times as wide and 50 times as long.
I appreciate all input, Thanks Ray