CSV Utilities
These are a few utilities for working with CSV files.
They are based on my AWK CSV Parser.
They are all written in Bourne shell and AWK.
The utilities currently included are:
- csv2csv - Converts between different formats of CSV.
Can also rearrange columns and perform other changes.
- csv2html - Converts to HTML with a high level of flexibility.
- csv2sc - Converts to the format used by the sc spreadsheet calculator.
- csv2sql - Converts to basic SQL.
I plan on adding more later.
I am working on one to convert CSV files based on templates.
Let me know if you have any ideas, I would love to hear them.
Email me at LoranceStinson+SDF AT gmail DOT com.
Each utility has options to specify the quote, escape and separator characters.
A simple test script is included.
It runs the utilities against test.csv and compares the results to test.out.
If the test fails or you encounter any errors please email me as much detail as possible.
My email address is LoranceStinson+SDF AT gmail DOT com.
I tried to think of any options that would be helpful.
Let me know if I missed any or there are any you think would be useful.
They are available as:
PKZip and
Gziped tar.
Last updated 2007-03-01.
Thu Mar 2007-03-01
- Now properly handles a newline right after a quote character.
See my AWK CSV Parser for details on the fix.
- Added checking for default escape, quote and separator characters
in the environment variables CSV_ESCAPE, CSV_QUOTE and OCSV_SEPARATOR respectively.
- Removed attempted doubling of \ character when used as an escape character.
This could cause confusion and was not a good idea.
NOTE:
There seems to be a bug in Mawk with regards to backslash characters.
The function gsub is used to escape special characters, like the quote and escape characters.
When the escape character is a backslash and Mawk is used only one backslash is output instead of the required two.
The hidden command line option -z will correct for this.
Only use -z if you are using Mawk, it will cause other AWKs to output three backslash characters.
Setting the environment variable CSV_MAWK_BUG to a true value will do the same thing.
Back