this.. might not throw an eror, but you have 2 keys with the same name "F", and 1 of them will probably be disgarded..., you have data corruption even before you try to process it.
{ "F": "False", "F": { "Int32": ["0", "0", "0"] }, } you mentioned Excel at one point. perhaps you could mock up what you'd like your finished data to look like in a spreadsheet (google docs for instance, since thats easy to link to) and reference there. just having a list of headers doesnt say much about the data format you want. "client wants csv" hmm..they want "csv" or they want "csv that fists this very particular description that fits our special decoder or the like" ? do you know how the client will use this data. could that info be used to simplify the output to some degree? and finally.. the client gives you malformed xml?? I'm very sorry to hear that. also does the client know they are emitting invalid xml? is it rly xml? is it valid in another language? (html is much more lenient for instance, an html parser might be able to gleam more meaning) by what definition is it malformed? is it outright structuralyl broken, does it fail to meet some schema? does it fail to meet some expectation you have for some reason ("client said it has these properties") you also mentioned you use JSON because it maps nicely to python dicts.. this is true ofc.. but why not just read that in to a python dict in the first place? > DB1 : 0, DB2: 0, DB3: 0 etc. and F1: 0, F1: 0. DB1, DB2 would be the headers > and the 0s as values in the CSV file. DB1 etc seems ok at first glance however... say there are 2 nested items and each of them have a DB property which is an array, you will have name collisions. you need more thought in to naming the headers at the very least. if this is meant for a spreadsheet.. then you will end up with 2 very very very long rows, it will NOT be readable by any stretch of the imagination.. do you want this. i'm afraid you'll essentially end up with a translation that looks sth like {A:{b:"c",q:"w"}} =============== "A.b", "A.q" "c", "w" if you just want key-value pairs there are better options out there..besides csv.. -- https://mail.python.org/mailman/listinfo/python-list