Bash CSV Handling

From TheBeard Science Project Wiki
Revision as of 14:00, 27 June 2019 by Beard (talk | contribs) (Quoted Strings with Commas)

Jump to: navigation, search

I'm sick of screwing this up, so I'm creating this definitive guide for my own reference. I will update this as I learn to handle individual issues.

Quoted Strings with Commas

When your fields are separated by commas, and one of the fields has a quoted string with a comma in it, it can screw up the parsing of the fields.

Here is a sample CSV file test.csv:

id,firstname,lastname,email,phone,hiredate
1122,"Colin","Quinn","c.quinn@example.com",1112223333,"02/12/2017"
2233,"Richard","Vos, Richard","r.vos@example.com",2223334444,"06/27/2019"
3344,"Patrice","O'Neal","p.o'neal@example.com",3334445555,"08/11/2018"
4455,"Jim","Jefferies","j.jefferies@example.com",,"09/11/2001"