Command fixed2xml


Name

fixed2xml converts a fixed field width file to an xml file

Synopsis

csv2xml [ serialization options ] [options] [fixedfile]


Options

-root rootnameuse "rootname" as the root element name, default "root"
-row rownameuse "rowname" as each row's element name, default "row"
-col colnameuse "colname" as each column's element name (or for attribute normal format, the attribute prefix)
-colspecs specssequence or , delimited list of column specs
-colnames namesUse a sequence or "," delimited list of strings to specify the column names
-encoding encodingread csv file in encoding (default "cp1252")
-headerread 1 row from the csv file and use as column names (element or attribute)
-attrOutput 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 linesSkip "lines" of lines before reading header or row data
fixedfileName 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 xml

fixed2xml -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>


Return Value

Returns 0 if the conversion is successful

Commands
CategoryCommands

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki