Have a csv file with tons of rows, small example:
id,location_id,name,title,email,directorate
1,1, Amy lee,Singer,,
2,2,brad Pitt,Actor,,Production
3,5,Steven Spielberg,Producer,spielberg@my.com,Production
Need to:
- change first and last name to uppercase, example, Brad Pitt, Amy Lee.
- create email with pattern first letter of first name + last name, all in lowercase with @google.com and value from location_id, example - ale1e@google.com, bpitt2@google.com
- save it to new file.csv, with the same structure, example:
id,location_id,name,title,email,directorate
1,1, Amy Lee,Singer,alee1@google.com,
2,2,Brad Pitt,Actor,bpitt@google.com,Production
3,5,Steven Spielberg,Producer,sspielberg@google.com,Production
I started from create a array and iterate through it, with bunch of sed, awk, but it gives to me random results. Please give me advice, how resolve this task.
while read -ra array; do
for i in ${array[@]};
do
awk -F ',' '{print tolower(substr($3,1,1))$2$3"@google.com"}'
done
for i in ${array[@]};
do
awk -F "\"*,\"*" '{print $3}' | sed -e "s/\b\(.\)/\u\1/g"
done
done < file.csv
awk -F ',' '{print tolower(substr($3,1,1))$2$3"@google.com"}'
working not correct.