escape
The escape command is useful if the system that is going to consume your CSV data requires that certain characters in the input be escaped. For example, some systems require that single-quotes be escaped. Note this is an application level issue - CSVfix handles CSV and SQL escaping for you automatically, so you should only need to use this command if the application consuming your CSV has special escaping requirements.
See also: edit
Flag |
Req'd? |
Description |
-s chars |
Yes |
Specifies a list of characters which need to be escaped. |
-e esc |
No |
Specifies the string that will be placed before each occurrence of each character specified by the -s flag. By default, escaping is performed with a single backslash. Any occurrences of the escape string in the input will themselves be escaped. |
-sql |
No |
Specifies that SQL-style escaping of single quotes, replacing them with two single quotes, should be performed. |
-f fields |
No |
Specifies the CSV fields to escape. If not provided, all fields are escaped. |
The following example escapes all the lower-case vowels in all fields in the names.csv file:
csvfix escape -s "aeiou" data/names.csv
which produces:
"Ch\arl\es","D\ick\ens","M"
"J\an\e","A\ust\en","F"
"H\erm\an","M\elv\ill\e","M"
"Fl\ann","O'Br\i\en","M"
"G\e\org\e","Ell\i\ot","F"
"V\irg\in\i\a","W\o\olf","F"
"Osc\ar","W\ild\e","M"
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation