xmlutils.py icon indicating copy to clipboard operation
xmlutils.py copied to clipboard

Missing element causes cell data to appear in the wrong column

Open dbooth-boston opened this issue 7 years ago • 0 comments

If an element is missing in the source XML, then the corresponding cell is erroneously omitted from the resulting CSV. This causes values in the resulting CSV to appear in the wrong columns.

This command:

xml2csv --input in.xml --output out.csv --tag "row"

On this input file, in.xml:

<?xml version="1.0"?>
<top>
  <row>
    <a>r1_col_a</a>
    <b>r1_col_b</b>
  </row>
  <row>
    <b>r2_col_b</b>
  </row>
</top>

Produced this output file, out.csv:

a,b
"r1_col_a","r1_col_b"
"r2_col_b"

Notice that r2_col_b is in column a, when it should be in column b.

dbooth-boston avatar Jun 16 '18 03:06 dbooth-boston