09-16-2024 09:12 AM
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
Solved! Go to Solution.
09-16-2024 09:55 AM
Hello Jean-François,
Could you try with a Json Splitter snap - after the script snap - to split the Array into individual documents?
09-16-2024 09:55 AM
Hello Jean-François,
Could you try with a Json Splitter snap - after the script snap - to split the Array into individual documents?
09-16-2024 10:14 AM
Hello Toni,
Yes, that did the trick! It was too simple, I didn't think about that... 🙂
Thanks a lot!
JF