Sample data ----------- - sample1.csv: comma and double quote, embedded commas and quotes - sample1a.csv: semicolon and single quote, embedded semicolons and quotes - sample1b.csv: comma and double quote, embedded commas, quotes and newlines - sample1c.csv: comma and double quote, embedded commas and quotes Simple, but not trivial, use cases ---------------------------------- (1) Print selected columns - CSV input: a,"b,c",d - CSV output: "b,c",d - Ideal code: { print $2, $3 } (2) Change separator - CSV input: a,"b,c",d - CSV output: a;"b,c";d - Potential code: BEGIN {FS="," ; OFS=";"} { $1=$1 ; print } (3) Change quote - CSV input: a,"b,c",d - CSV output: a,'b,c',d - Potential code: BEGIN {CSVINQ="\"" ; CSVOUTQ="'"} { $1=$1 ; print } # new variables? (hmm..) (4) Change selected column - CSV input: a,"b,c",d - CSV output: a,'B|C',d - Potential code: BEGIN {CSVOUTQ="'"} { $2 = "B|C" } (5) Change column and quote - CSV input: a,"b,c",d - CSV output: a,"B|C",d - Potential code: { $2 = "B|C" } # Note; no escaped quotes in string "B|C" (not "\"B|C\"") (6) Append column - CSV input: a,"b,c",d - CSV output: a,"b,c",d,"e f" - Potential code: { $0 = $0 "e f" } (7) Append column, manually formatted - CSV input: a,"b,c",d - CSV output: a,"b,c",d,"e f" # implicit knowledge of CSV format? (hmm..) Or explicit format - Potential code: { $0 = $0 ",\"e f\"" } # not very supportive (8) Prepend column - Potential code: { $0 = "e f" $0 } # analogous comments like in previous function (9) Insert Colum (at arbitrary positions!) - CSV input: a,"b,c",d - CSV output: a,"b,c",xy,d - Potential code: # I have no idea at the moment (10) Use of escapes in data - CSV input/output: a,"b\"c",d # Will that be handled in the extension in some way? (\" or "")