Sample Header Ad - 728x90

How to create a new column and add a random identifier to it with miller

3 votes
5 answers
510 views
I want to add a column with a randomly created "case number" to my csv file. The first 2 letters of the casenumber must be any letter from A-Z in capitals. followed by 5 random numbers. input:
COMPANY,NAME,STREET,ZIP,CITY,IBAN
Test Ltd,John,Big Ben 343,4343,London,UK2348020384
Test Ltd,Kate,Big Ben 343,4343,London,UK4389223892
Test Ltd,Jake,Big Ben 343,4343,London,UK3892898999
output
COMPANY,NAME,STREET,ZIP,CITY,IBAN,CASENUMBER
Test Ltd,John,Big Ben 343,4343,London,UK2348020384,IN84903
Test Ltd,Kate,Big Ben 343,4343,London,UK4389223892,TY93842
Test Ltd,Jake,Big Ben 343,4343,London,UK3892898999,OL34307
How to do this with miller? I have the following command ready
mlr -I --csv put '${CASENUMBER}=xxx' then \
	reorder -f COMPANY,NAME,STREET,ZIP,CITY,IBAN,CASENUMBER input/input.csv
What to add to the above command exactly?
Asked by pwrsheller (357 rep)
Jan 29, 2024, 09:07 AM
Last activity: Jan 30, 2024, 01:18 PM