Revision [1496]
This is an old revision of CommandCsv2xml made by DavidLee on 2010-08-11 07:40:59.
Command csv2xml
Name
csv2xml converts a csv file to an xml fileSynopsis
csv2xml [ serialization options ] [options] [csvfile]Options
-root rootname | Use "rootname" as the root element name, default "root" |
-row rowname | use "rowname" as each row's element name, default "row" |
-col colname | use "colname" as each column's element name (or for attribute normal format, the attribute prefix) |
-colnames names | Use a sequence or , separated list of strings to specify the column names |
-delim delimchar | deliminate columns with delimchar, default "," |
-tab | Use tab char as delimitor. Synonymous for -delim <[ "	" ]> |
-quote quotechar | quote with quote character, default " |
-encoding encoding | read csv file in encoding (default "cp1252") |
-header | read 1 row from the csv file and use as column names (element or attribute) |
-attr | Output in attribute normal format (each column is an attribute), default row normal format |
-skip lines | Skip # lines before reading header or data |
csvfile | Name of the csv file to convert, otherwise stdin. Default "-" (stdin) |
Supports the standard [ serialization options ]
If -colnames is specified, its argument is taken to be either a sequence of strings, or a single string which is "," seperated which specifieds the column names to be used.
if -header is specified then the first row of the CSV file is read and the values used as column names.
If both -colnames and -header are specified then -colnames takes precedence but the header is still read (and ignored).
Examples
Example
echo foo,bar | csv2xml
Result
<root> <row> <col>foo</col> <col>bar</col> </row> </root>
Return Value
Returns 0 if the conversion is successfulCommands
CategoryCommands