Merge of n delimited files from folder

One Star

Merge of n delimited files from folder

Hello
I have n files in the same folder.
All files have the same structure (*.TXT files, delimited with a Smiley Wink
First line is for the fields name
I want to merge all the n files into one file keeping the same structure (where first line is for the fields name)
I do the following :
tFileList-----tFileInputDelimited------tFileOutputDlimited
tFileListe read all the files as I can read from stats when i run the job.
tFileInputDelimited is set to read the current file from ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"))
For the schema, I have manualy created 7 rows and kept them in string format (Maybe there is a way that the list of the row will be read from the file)
tFileOutputDelimited is set to append and to sync rows
When I launch the job it looks it is working but at the end I have a blank file !
-------------------
EDIT IF SOMEONE HAS THE SAME PROBLEM
--------------------
I don't know why but if I change the output file extension from csv to txt it now works !!!
Now my question is : Is there a way to get the fiels name (ie the schema at tFileInput level from the reading of the files)
Now I have to manualy create n rows so I end up with something.
Problem are : I don't want to manualy recreate the structure each time
Thanks for your feedback.
Moderator

Re: Merge of n delimited files from folder

Hi,
When I launch the job it looks it is working but at the end I have a blank file !
I don't know why but if I change the output file extension from csv to txt it now works !!!

Did you check the "Trim" option for your input component to avoid extra space in your source file? How did you set your field separator, row separator?
Now my question is : Is there a way to get the fiels name (ie the schema at tFileInput level from the reading of the files)

For your issue, you want get the n files name? Or dynamic schema?
If the former, you should add another iterate from tfilelist and link to tfixedflow. See my screenshot
If the later, dynamic schema is only available in Talend Enterprise Subscription Version.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Merge of n delimited files from folder

Hi Sabrina and thanks for the quick feedback.
I'll take a look at the TRIM option et separator.
For the second question, what I understand is that if I want to get the schema automaticaly from the input, I must have the subscription version.
Meaning, I have to manualy write the schema at the tInputDelimited level ?
Sounds clear to me now.
Thanks a lot
Moderator

Re: Merge of n delimited files from folder

Hi,
For the second question, what I understand is that if I want to get the schema automaticaly from the input, I must have the subscription version.
Meaning, I have to manualy write the schema at the tInputDelimited level ?

Yes, dynamic schema feature is only available in Talend Enterprise Subscription Version. It allows you to design schema with an unknown column structure (unknown name and number of columns, or create schema automatically without one by one).
Please related KB article TalendHelpCenter: How to process changing data structure?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.