Hi Linux Experts,
I have the following problem to solve:
-Below is the CSV file give
firstname,lastname,password,username,notes,city,phonenumber
fred,smith, notgood1, fredsmith, this user\, is the first in this file, Brighton,345698
Peter, Bloggs, anotherbad,peterbloggs,,London,987123
Jo, cooper, notmuch, jcooper, this user is Jo, Brighton, 456987
john, carter,nearlyempty,jcarter,This note is actually very long\, but really doesn't say anything very useful,,345777
sam,jones,passing, samjones, Not much of a note really, Manchester, 135790
- capitalise the first letter of the two name fields
- sanitise the formatting
- move the username column to the beginning of each line
- the phone number is missing the area code - look up the city in the following table, and add it to the beginning of the phone number column:
City, Area Code
London, 5
Brighton, 6
Manchester, 7
Provide the corrected CSV file.
One of the problems I have is that whenever I use the comma as FS the output for column 5 is the following
cat Test.csv | awk 'BEGIN { FS = "," } {print $5 }'
notes
this user\
this user is Jo
This note is actually very long\
Not much of a note really
It stops in the middle of the entry because it sees the comma but what I am trying to achieve is to produce the full entry for column 5 like this:
this user\, is the first in this file
This note is actually very long\, but really doesn't say anything very useful
I have to probably escape somehow the FS in the text but so far no joy with completing this task. Also can you kindly help out for the rest of the requirements.
I really appreciate your help in advance.
Ivan