Forum Discussion
heidi_andrew - Depending on the file contents in the zipfile, if you are using the ZipFile Read snap, it sends each file to the next snap as a binary document. For example, if the files are all the same CSV layout, you can simply place a CSV Parser after the ZipFile Read snap and it will process all incoming files as a consistent stream.
Or if the zipfile is an archive of different files, you can use the Binary Router and inspect the "content-location" element which is the filename and send the streams to the appropriate parser for further processing.
Use "Validate Pipeline" to inspect the Zipfile Read output to get a better understanding of what the snap is doing.
Hope this helps!
Are you expecting to process
$shoppingHistoryList.shoppingHistory
on its own or are you merging it with$input1_shoppingHistoryList.shoppingHistory
where each element in$shoppingHistoryList
corresponds to an element in$input1_shoppingHistoryList
?Thank you @tstack for the reply, I need to merge with
$input1_shoppingHistoryList.shoppingHistory
where each element in$shoppingHistoryList
corresponds to an element in$input1_shoppingHistoryList
but, the remaining fields in ‘$shoppingHistoryList.shoppingHistory’ should not be changed.You can do this with the expression language inside of a Mapper. For merging the arrays, you can use the
sl.zip()
function, like so:sl.zip($shoppingHistoryList.shoppingHistory, $input1_shoppingHistoryList.shoppingHistory)
The result of that expression will be an array of pairs containing the element from the first array and the corresponding element from the second array. Once they are grouped together, you can use a
map()
method on the array to iterate over the pairs and then useextend()
method to update the properties in the element from the first array with properties from the element in the second:sl.zip($shoppingHistoryList.shoppingHistory, $input1_shoppingHistoryList.shoppingHistory).map(x => x[0].extend(x[1]))
Here’s an example pipeline that does this mapping:
ReplaceFields_2018_12_16.slp (5.7 KB)
You can use replace expression to perform your conversion logic at ease but what is not clear is if you like to have this done dynamically, what exact mechanism would you like it to do? Based on the position of the array? or there are some other logic or fuzzy logic (less ideal)?
Thanks @aleung for your reply… It should be done dynamically based on the position of the array. The $input1_shoppingHistoryList.shoppingHistory is nothing but the transformed values of the $shoppingHistoryList.shoppingHistory based on the sql mapping table.
Related Content
- 7 years ago
- 6 years ago