Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Aish123
Contributor
Contributor

how to split a csv file into multiple files depending on the date pattern

Hi,

 

I have a csv files with multiple records. I want to split the files into multiple csv files considering the year specified in the Invoice date column.

 

The output should be

samplefile_2007.csv consisting only the 2007 data and similarly for the remaining files,

samplefile_2008.csv

samplefile_2009.csv

samplefile_2010.csv and so on

0683p000009MZtN.png

Labels (2)
3 Replies
akumar2301
Creator III
Creator III

You can create a new column with with year only and then split it based on its value.

https://community.talend.com/t5/Design-and-Development/Split-an-input-csv-file-into-multiple-output-...

Aish123
Contributor
Contributor
Author

Hi @uganesh ,

 

It would be really helpful if you could show this in an pictorial form with the component details specified.

 

I saw the example which you have mentioned in the your reply. I dont want to manually type in the name of the files .

 

Can you help me with any other solution?

 

This is the solution provided by you in one of the post ..can you please elaborate on what exactly needs to be done on tjavarow component?

https://community.talend.com/t5/Design-and-Development/Split-into-multiple-files-based-on-Date-Value...

 

akumar2301
Creator III
Creator III

Yes you are right . it is same requirement.you need not type the name manually .

 

1) Put file name is globalvar say gVar_fileName (or context variable from input)

2) Read file -- > add col4 which in YYYY format of Col3(TjavaRow)

--> file uniq on col4 in ( tUniqRow)

-- > tflowtoItrate( put col4 in GlobalVar e.g. gVar_year )

--> read file again

--> tFilterRow on GlobalVar

--> tFilerOutPut

        ( Filename here could be gVar_fileName  + "_" + gVar_year + ".csv")

 

is it ok ?