Skip to content Skip to sidebar Skip to footer

How To Convert The Columns From A Csvfile Into An Ordereddict Python

I have a csv file and i need the columns to be printed as OrderedDict I am able to convert the rows into an ordereddict using collections.OrderedDict((row[0], row[1:]) for row in

Solution 1:

try using this

od = collections.OrderedDict((row[0], row[1:]) forrowin r if len(row)>1)

this might be you have row with only one column

Post a Comment for "How To Convert The Columns From A Csvfile Into An Ordereddict Python"