Command fixed2xml
Name
fixed2xml converts a fixed field width file to an xml fileSynopsis
csv2xml [ serialization options ] [options] [fixedfile]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) |
-colspecs specs | sequence or , delimited list of column specs |
-colnames names | Use a sequence or "," delimited list of strings to specify the column names |
-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 |
-nonorm | "No Normalize" ... Do NOT trim leading and trailing blanks from fields (defaults to normalize) |
-skip lines | Skip "lines" of lines before reading header or row data |
fixedfile | Name of the fixed 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 fixed file is read and the values used as column names.
-colspecs is required. Its argument is a sequence or "," deliminted string of column specs. A column spec is either "start-end" or "start", where start and end are integer column positions starting at one. For example "1-3,5-6,7-9" or <[ "1-3" , "5-6" , "7-9" ]>
If the "-end" is omitted then the remainder of the line is used.
Column specs may overlap (e.g "1-10,5-12" )
Examples
Convert a file with 3 fields of widths 6,4,4 and field names First, Second, Third to xmlfixed2xml -row item -root items -colspecs 1-5,7-9,11-15 -colnames First,Second,Third <<EOF FOO BAR SPAM GOOO BAH SPA EOF
Result
<items>
<item>
<First>FOO</First>
<Second>BAR</Second>
<Third>SPAM</Third>
</item>
<item>
<First>GOOO</First>
<Second>BAH</Second>
<Third>SPA</Third>
</item>
</items>
<item>
<First>FOO</First>
<Second>BAR</Second>
<Third>SPAM</Third>
</item>
<item>
<First>GOOO</First>
<Second>BAH</Second>
<Third>SPA</Third>
</item>
</items>
Return Value
Returns 0 if the conversion is successfulCommands
CategoryCommands