CSV parser cannot parse data
Hello all,
I'm extracting data from a structured XML file using a Python script (the build-in SnapLogic XML parser cannot handle it), and I return the results as a list of dictionaries, and I want to convert this into a CSV file.
The output from the Python script looks like this:
[
[
{
"SourceLang":"en",
"TargetLang":"fr",
"SourceText":"English text",
"Translation":"Translated English text"
},
{
"SourceLang":"en",
"TargetLang":"fr",
"SourceText":"More English text",
"Translation":"More translated English text"
}
]
]
I would expect this to be easily converted to CSV, but this is the error message that I'm getting:
Failure: Cannot format CSV data, Reason: Input document should be a flattened map data, but found: ArrayList, Resolution: Please make sure the input document a flattened map data.
Is there any way to convert this "ArrayList" into a flattened map data that I can convert to CSV?
Thanks in advance!
JF
Yeah, I finally realized that Join snap cannot handle joining fields into same top-level structure so I eliminated the top level structure for the join, and then used a mapper to add the top-level structure back. I had to write a custom snap (not included) to prune off all the null fields/elements created by the Null Safe Access mappers…
I must say that was a lot more painful than I think it should be. If I were to use this in an actual business process, the logic of the business process flow would get lost due to this complex mapping flow…
Here is the final working example (with all of the nulls still present).
Mapping Conundrum_2020_09_30 (3).slp (56.6 KB)
Thanks for the help,
Robert