cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Get input file name from CSV parser

rajesh_mangipud
New Contributor II

Hi,

I have a set of CSV files that I read from using a CSV Parser. Is there a way the CSV Parser can also output the name of the file. I have already thought of putting the CSVParser in a child pipeline and feed the name of the pipeline as a parameter and reading that out. But I was wondering if there was a better way.

Best,
Rajesh

3 REPLIES 3

deepak_shaw
Contributor

HI @Rajesh,
I tried with Binary router and extracted the file name from content-location. see the attached screenshot -
image

Does this help?
Regards,
Deepak.

rajesh_mangipud
New Contributor II

Thanks Deepak. I have thought of that approach and then doing a cross join back to the main stream, but that does not seem to work when the input has multiple files.

So if there are 5 files and each file has 5 records, I need to write 25 records to the destination with each source file name identified (a column in the destination table)

Hi Rajesh,
Probably too late to answer, you can achieve this by calling a child pipeline with filename and path as pipeline parameters.
Read the file in child, map data, use _filename as another column in mapper.

Get result of all the child pipelines in parent pipeline to combine into single file.