Revision [865]

This is an old revision of CommandFixed2xml made by DavidLee on 2009-11-22 07:20:04.

 

Command fixed2xml


Name

fixed2xml converts a fixed field width file to an xml file

Synopsis

csv2xml [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)
-cols colseq Use a sequence of strings to specify the column names
-widths widthseq Use the specified sequence of widths to define the fields
-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)
fixedfile Name of the fixed file to convert, otherwise stdin. Default "-" (stdin)



Example

Convert a file with 3 fields of widths 6,4,4 and field names First, Second, Third to xml

fixed2xml -row item -root items -widths <[ 6,4,4 ]> -cols <["First","Second","Third"]>  <<EOF
FOO   BAR SPAM
GOOO  BAH SPA
EOF

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

CategoryCommands

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