cancel
Showing results for 
Search instead for 
Did you mean: 

CSV parser cannot parse data

jfpelletier
Contributor

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

1 ACCEPTED SOLUTION

tbranco
Employee
Employee

Hello Jean-François,

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

 

View solution in original post

2 REPLIES 2

tbranco
Employee
Employee

Hello Jean-François,

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

 

jfpelletier
Contributor

Hello Toni,

Yes, that did the trick! It was too simple, I didn't think about that... 🙂

Thanks a lot!

JF