Jan-09-2018, 05:00 AM
Here is what I need to do.
1. I have an existing CSV file with 12 columns in it containing financial information. This CSV is sorted. I need to ADD two columns: 'product item number' (a 7 digit int) and 'product item number ID' (a 6 digit int).
2. Once I add the two columns, I need to write a number into the first row for that column and then add 'one' to the number in each subsequent row cell in that column so that each subsequent cell is one more than the previous, i.e. the number increases sequentially with each row in the sort. I need to do this for both 'product item number' and 'product item number ID'.
My main problem is putting the csv writer into a loop so I can increment the variable and write it into subsequent cells in the loop. I have looked at DictWriter, pandas concat (axis 1) and similar. Any help would make my week....thank you very much!
1. I have an existing CSV file with 12 columns in it containing financial information. This CSV is sorted. I need to ADD two columns: 'product item number' (a 7 digit int) and 'product item number ID' (a 6 digit int).
2. Once I add the two columns, I need to write a number into the first row for that column and then add 'one' to the number in each subsequent row cell in that column so that each subsequent cell is one more than the previous, i.e. the number increases sequentially with each row in the sort. I need to do this for both 'product item number' and 'product item number ID'.
My main problem is putting the csv writer into a loop so I can increment the variable and write it into subsequent cells in the loop. I have looked at DictWriter, pandas concat (axis 1) and similar. Any help would make my week....thank you very much!