i'm struggling a bit here. I have the following code (with the help of some other great python experts here):
skip = [11, 15, 30, 31, 32, 34, 41, 45, 55, 58, 59, 62, 64, 65, 66, 67, 68, 69,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80]
#skip += range(64, 70)
#skip += range(71, 81)
with open(outname, 'r') as r, open('import2SFDC.csv', 'w') as w:
reader = csv.reader(r)
writer = csv.writer(w, delimiter=',', quoting=csv.QUOTE_ALL)
header = next(reader) # "next" is the first row in this case, i.e. the header row
header.append('SFDCID') # Add the new column
writer.writerow(header) # write out the new header
for row in reader:
new_row = [v for k, v in enumerate(row) if k not in skip]
new_row.append(args.SFDCID)
writer.writerow(new_row)
For whatever reason skipping the columns defined in the skip variable doesn't work. I'm sure it's an obvious thing, but I'm looking into the code and trying to fix it for hours now, I just can't get it to work.
any help is highly appreciated.
thanks