One Star

How insert file name into MySQL table

Hello there!
I think I have a simple question but I'm not managing to get this done. I've also researched on how to make it but couldn't find the answer so I hope you can help me
I have the following task:
In a directory I have like 200 text files that I read using a tFileList component. This data is sent to a tFileInputDelimited that parses the columns that I need (like info of the customers, when they bought stuff, what they bought and so on).
Finally, I save this data into a table from a mysql server. What I also need to do now is to save 2 more data into this table, and it's the name of the file where the processed row came from and in which row from the file it was read.
So for instance, if I have a file1.txt, I need to save in a column 'NameofFile' the name 'file1', and also if it's on the third row I need to save in the column 'RowCount' the number 3 and so on.
As I'm still learning Talend I don't know how to get this done. Is it possible to make this task?
Thanks very much in advance!
Willian
2 REPLIES
One Star

Re: How insert file name into MySQL table

Hi,
Take a look at these two blog posts. The first one describes a file processing loop
http://bekwam.blogspot.com/2011/02/staging-data-for-etl-processing-with.html
This one shows how to use tFileList with a DATA_DIR directory specified as a context variable
http://bekwam.blogspot.com/2011/02/excel-workbook-processing-with-talend.html
-Carl
One Star

Re: How insert file name into MySQL table