archiecobbs / csvprintf

Simple CSV file parser for the UNIX command line
Apache License 2.0
40 stars 3 forks source link

Option to use header entries as column names in xml #1

Open col-panic opened 9 years ago

col-panic commented 9 years ago

Consider your csv example, could you add an option '-u 1' that uses the first line of the csv as naming scheme for the xml output column names?

So for example the following output would happen

$ cat input.csv | csvprintf -ix -u 1
<?xml version="1.0" encoding="ISO-8859-1"?>
<csv>
  <row>
    <NAME>Fred Smith</NAME>
    <ADDRESS>1234 Main St.
Anytown, USA   39103</ADDRESS>
    <POINTS>123.4567</POINTS>
  </row>
  <row>
    <NAME>Wayne &quot;The Great One&quot; Gretsky</NAME>
    <ADDRESS>59 Hockey Lane</ADDRESS>
    <POINTS>999999</POINTS>
  </row>
</csv>

thanks a lot

archiecobbs commented 9 years ago

Good idea. I'll take a look when time permits.