-
-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Description
Assume this is the input ledger.csv:
transaction uuid,date,payee,amount aaa123,2024-03-01,Bill's Garage,50 aaa123,2024-03-01,Bank account,50 456abc,2024-03-05,Solar Power Monopoly,200 456abc,2024-03-05,Credit card,200and that we define a gawk program, seq.awk, which adds sequence numbers within transaction uuid:
# seq.awk: BEGIN { OFS = "," } NR == 1 { print $0, "n" } NR > 1 { if ($1 == prev) ++n; else n=1; prev = $1; print $0, "payee " n }Then we can run:
gawk --csv -f seq.awk ledger.csv | csvtk spread -k n -v payeegiving
transaction uuid,date,amount,payee 1,payee 2 aaa123,2024-03-01,50,Bill's Garage,Bank account 456abc,2024-03-05,200,Solar Power Monopoly,Credit cardI didn't notice anything in csvtk for adding sequence numbers by group but if it exists we could use that in place of the gawk program.
Originally posted by @ggrothendieck in #320
Metadata
Metadata
Assignees
Labels
No labels