Have a script
#!/bin/bash
sed -E 's/([^,]*,([^,]*),) ?(([[:alpha:]])[^ ]* +)(([^,]*),[^,]*,)[^,]*/\1\u\3\u\5\L\4\6\[email protected]/' file.csv > output.csv
Have a file.csv:
id,location_id,name,title,email,directorate
1,1, Amy Lee,Singer,,,
2,2,brad Pitt,Actor,[email protected],Production
3,5,steven spielberg,Producer,Screenwriter, [email protected],Production
4,8,Andy lee,Comedian,,Radio
A few problem, that I need resolve:
- title value can be more than one title, example: Steve Spielberg - Producer,Screenwriter. Now the script cuts off the value after the comma, but I need to save all titles.
- script concatenate first letter of first name and a last name, plus location_id and @google.com, but I need add location_id, only when have a equals emails.
In the end it should be:
id,location_id,name,title,email,directorate
1,1, Amy Lee,Singer,[email protected],,
2,2,Brad Pitt,Actor,[email protected],Production
3,5,Steven Spielberg,Producer,Screenwriter,[email protected],Production
4,8,Andy Lee,Comedian,[email protected],Radio
@in email and deduce its location you're out of luck if the email is missing.,,,,,,,,,,. Which one is the entry with comma inside a field? Only correct user input will tell you e.g.,,,",,,,,",,