I am looking into automating some processes / calculations but I may first need to format a slightly awkward CSV file set. (For this I am using bash
, as requested).
The csv file set follows (roughly) the format below
CODE,Sitting,Jan,Feb,Mar,Apr,May,Jun,Jul,Totals
CLLK_J9,First Sitting,,,2,5,2,,,10
,Second Sitting,,,,,,,,1
RTHM_A8,First Sitting,,,1,,3,,,6
,Second Sitting,,,,,1,,,1
FFBJ_FA9,First Sitting,,,,8,6,,,25
,Second Sitting,,,,,11,,,12
UUYIOR_HJ9,First Sitting,,,1,3,6,,,17
IKRO_Lk8,First Sitting,,,,3,3,,,37
,Second Sitting,,,,6,11,,,34
I am trying to fill in the empty fields in the column CODE
with the content of the field from the previous line (ordinarily these empty fields occur next to a "second sitting" instance in column 2). So, for the above example, the result should be like
CODE,Sitting,Jan,Feb,Mar,Apr,May,Jun,Jul,Totals
CLLK_J9,First Sitting,,,2,5,2,,,10
CLLK_J9,Second Sitting,,,,,,,,1
etc.
I am starting to read some awk
documentation as it seems a reasonably powerful utility for this task - but haven't made any progress yet. Thoughts?
ta