|
ParseCSV |
Pipelines v1.9 |
.* Example by TenFiftyTwo(c). |
.* The following pipeline handles two input arguments:.*.* &arg1. The CSV field delimiter..* &arg2. The character which will replace the CSV delimiter..*.* The following pipeline replaces the CSV field delimiters in each input record with the character.* specified in: &arg2. The modified records are written back to the caller; who can then.* operate on them, in terms of words and fields. .* Note: the caller must restore the original CSV delimiter character if the records are to be written.* to a CSV file. pipe (stagesep !)
in .* Read records from the caller. ! specs 1-* 1 xfefe n .* Tag the end of the record. .* Parse/split the record into its individual fields. ! split before reg /(\s"\s([^"]*|"{2})*"(&arg1|))|"[^"]*"(&arg1|)|[^&arg1]+(&arg1|)|(&arg1)/ ! specs 1;-2 1 &arg2 n .* Tag the end of the field with the new field delimiter. ! split before str xfe .* Split off the end of record tag, and join.. ! join until 1 xfe .* ..the fields back together. ! out .* Write records back to the caller.