cancel
Showing results for 
Search instead for 
Did you mean: 

Rest Get output is in filename.json.gz format need to convert to csv

deeps
New Contributor III

Hello All,
I have file called “filename.json.gz” which is obtained using REST GET Snap and I need to convert it to a CSV format file. I need this transformation to be done in one pipeline.
Any help would be greatly appreciated. Thanks!!

1 ACCEPTED SOLUTION

ddellsperger
Moderator
Moderator

GZip stuff is a little bit more work, but it’s possible here, you’ll want to set the REST Get Response Entity Type to BINARY
image
With that, you’ll then have to map the data from the output document to content for a document to binary transition, to do this, you’ll want to map the settings in the mapper (some of these are optional, but I’d say content-type, content-encoding, and content are all required on the output map)
image
With that, you can use the Document to Binary to get it in a binary form (I set the drop-down for Encode or Decode to NONE), then decompress (you select GZip), then you can parse the JSON with the JSON Parser.

Full pipeline screenshot
image
download (you’ll need to change the URL to download in the REST Get)
json gzip_2023_03_03.slp (8.0 KB)

View solution in original post

4 REPLIES 4

Aleksandar_A
Contributor III

Hi @deepthi.chidi.

You can try by splitting the entity from the Rest Get Response and then using CSV Formatter.

image

Let me know if this helps you.

BR,
Aleksandar.

deeps
New Contributor III

Hello Aleksandar,

I did try but it didn’t work.
Here is how my REST SNAP output looks like and I need to read data that’s in filename="Test_2023_02_10.json.gz\

[{“statusLine”:{“protoVersion”:“HTTP/1.1”,“statusCode”:200,“reasonPhrase”:“OK”},“entity”:“abcd”,
“headers”:{“vary”:“Accept-Encoding”,“x-powered-by”:“153.1”,“x-accepted-oauth-scopes”:“analytics:read”,“transfer-encoding”:“chunked”,“pragma”:“private”,“via”:“envoy, envoyozak”,“date”:“Fri, 03 Mar 2023 GMT”,“x-oauth-scopes”:“identify.analytics:read”,“content-disposition”:“attachment; filename="Test_2023_02_10.json.gz"; filename*=utf-8’'Test%202023-02-10.json.gz”,“access-control-allow-headers”:“hyyuy”}}]

Thank you !

ddellsperger
Moderator
Moderator

GZip stuff is a little bit more work, but it’s possible here, you’ll want to set the REST Get Response Entity Type to BINARY
image
With that, you’ll then have to map the data from the output document to content for a document to binary transition, to do this, you’ll want to map the settings in the mapper (some of these are optional, but I’d say content-type, content-encoding, and content are all required on the output map)
image
With that, you can use the Document to Binary to get it in a binary form (I set the drop-down for Encode or Decode to NONE), then decompress (you select GZip), then you can parse the JSON with the JSON Parser.

Full pipeline screenshot
image
download (you’ll need to change the URL to download in the REST Get)
json gzip_2023_03_03.slp (8.0 KB)

deeps
New Contributor III

Thank you, it worked.