cancel
Showing results for 
Search instead for 
Did you mean: 

Zip File Read – pass file name to text field

Regina
New Contributor II

Hello, we have a data coming in a zip file. One of the requirements is to read file name and send it to a text field so it can be loaded in to one of the columns in Oracle table.

For example:

File name is SV_4YEVwN5KjncCtVj.zip

Output result (Oracle table):
image
Below is a pipeline I have:
image
ZipFileRead produces following result.
image
How can I extract “SV_4YEVwN5KjncCtVj” from the "zip-filename": "file:///C:/Users/SVC_SN~1/AppData/Local/Temp/sl_pipe_bdca1c58-dd15-403e-9b86-5b6c38102d1b/SV_4YEVwN5KjncCtVj.zip"
and pass it to a JSON Splitter?
image
Any suggestions would be greatly appreciated.
Thank you!
Regina

8 REPLIES 8

tstack
Former Employee

(As you found out, using BinaryToDocument is one approach, I’m just offering another for reference)

I can offer a solution that is possible if you’re on the new 4.16 release. Since the JSONParser doesn’t pass through the header from the binary document, you can use a child pipeline to do the parsing and pass the filename as a pipeline parameter that can be referenced anywhere in the child pipeline. This approach is possible in 4.16 since the PipelineExecute snap can now support binary views.

You can switch the type of view by going into the “Views” tab and changing the value under the “Type” column for the given view:

pipe-exec-bin-view

So, your pipeline will look something like the following with the binary documents from the zip file going into a child pipeline:

image

And, the $['content-location'] field containing the file name being passed as a parameter to the child execution in the PipelineExecute:

image

The child pipeline would then have the JSONParser and a Mapper to add in the $FileName field:

image

I’m attaching the parent and child pipelines as well:

ParseJsonWithFilename_2019_02_18.slp (4.5 KB)
ReadZipFileAndParse_2019_02_18.slp (3.7 KB)

dmiller
Former Employee

Correct, it would not come through this way. My apologies for not including an image early. My intent was to collect the information earlier in the pipeline, Copy it out to a second branch, then join it back in with a Join or Union, whichever is appropriate for the data.

18%20AM

As @tstack said, there are several ways to do the same thing.


Diane Miller

Regina
New Contributor II

Thank you, Diane and Tim! All information is very helpful

Regina
New Contributor II

I found solution for this one by replacing JSON Parser with the Binary to Document Snap:
image
Encode or Decode property should be set to “Document”
image

Thank you for your help!