I have a list of numbers imported from excel, an example line looks like this...
70609,86,91,,66 ,66,
I would like a N/A to be inserted in between the two commas and after the last one.
This is the code I have so far, but I haven't gotten it to work.
70609,86,91,,66 ,66,
I would like a N/A to be inserted in between the two commas and after the last one.
This is the code I have so far, but I haven't gotten it to work.
Code:
f = open("C:\users\cory\desktop\code\Verification.csv")
dd = {}
keys = f.readline().strip().split(',')
for key in keys:
dd.setdefault(key, [])
for line in f:
elements = line.strip().split(',')
for i, item in enumerate(elements):
if element == "":
dd[keys[i]].append("N/A")
else:
dd[keys[i]].append(int(item))
f.close()
for key in keys:
print "%s: %s" % (key, dd[key])
Comment