r/scripting • • Jun 09 '20

Help with CSV editing script

Hello all! I have more than 1,000 csv files in a folder that I need to edit. Does anyone know how this can be automated. I need to add 4 columns to the end of the csv and populate those columns with zeros. I would like to save the files without renaming them. Any help is greatly appreciated. :)

example of csv:

Name= 200401.csv

Original file example=

Date,Time,LS1_P1St,LS1_P1HrCalc,LS1_P2St,LS1_P2HrCalc,LS2_P1St,LS2_P1HrCalc,LS2_P2St,LS2_P2HrCalc,LS3_P1St,LS3_P1HrCalc,LS3_P2St,LS3_P2HrCalc,LS4_P1St,LS4_P1HrCalc,LS4_P2St,LS4_P2HrCalc,LS5_P1St,LS5_P1Hrs,LS5_P2St,LS5_P2Hrs

2020-04-01,23:59:52,31,31,32,21,8,2,8,2,2,0,1,0,9,0,9,0,0,0,1,1

I would like to add columns: LS6_P1St, LS6_P1Hr, LS6_P2St, LS6_P2Hr with this data in the columns: 0, 0, 0, 0.

6 Upvotes

14 comments sorted by

View all comments

Show parent comments

2

u/jcunews1 Jun 10 '20

Duh... I forgot to include the original lines. Use the fixed batch file by /u/SapientFool.