JSON Object to CSV File Troubleshooting

Denis McMahon denismfmcmahon at gmail.com
Sun Jun 21 19:33:17 EDT 2015


On Mon, 22 Jun 2015 00:55:11 +0300, Joonas Liik wrote:

> In xml for instance this is valid:

> <a>
>  <b>1</b>
> </a>
> .. and so is this:
> <a>
>  <b>1</b> <b>2</b>
> </a>

What the OP needs to do is sit down with the XML and work out how it 
needs to be represented in CSV terms, and then code that transformation, 
but it appears that he's not listening.

ie, does your xml:

<a>
  <b>1</b> <b>2</b>
</a>

translate to CSV:

"a","b"   // headers
"b",1     // data row 1
"b",2     // data row 2

or to CSV:

"a", "b", "b"     // headers
"", 1, 2          // data row

or even CSV:

"b"   // headers
1     // data row 1
2     // data row 2

If he can't codify that in a consistent manner across all the XML he 
wishes to process, then he really does need to find someone competent to 
do the job instead of wallowing around in json until the client gives up 
in despair at the lack of progress and finds someone else to do the job.

This should really have been defined by whoever set the task to do the 
conversion. If the job is to convert from some XML DTD to a CSV format, 
then there should be a clear description of what extracts from the XML 
are expected to be in which positions in the CSV.

This is the sort of data conversion code I generally turn out in a day or 
so, it's hardly rocket science as long as you have a clear description of 
what is required. If you don't have a clear description of what is 
required, you have to keep asking questions until you get one.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list