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 II

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
Employee
Employee

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

AleksandarAngel
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 II

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
Employee
Employee

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 II

Thank you, it worked.