Forum Discussion

jfpelletier's avatar
jfpelletier
Contributor
11 months ago
Solved

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

  • Hello Jean-François,

    Could you try with a Json Splitter snap - after the script snap - to split the Array into individual documents?