Load file content and filename into database

One Star

Load file content and filename into database

I am currently trying to use talend to load all text files contained in a directory into an Oracle database.
I want to load the complete content of each of these files into one field, therefor tFileInputRaw seems best suited for me.
Additionally I need to load the source file name into a second column. Can anybody help me on how to achieve this?
The destination table was created with following query:
 
CREATE TABLE message_table (message CLOB, filename VARCHAR(256));
 
Thanks a lot!
Community Manager

Re: Load file content and filename into database

Hi 
Take a look at this KB article, it shows how to iterate all files in a directory and insert them into database. 
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Load file content and filename into database

Thank you.
The second part of my question is, how do I load the filename together with every filecontent into the database?
Community Manager

Re: Load file content and filename into database

tFileList declares a global variable that stores the current file name, for example:
((String)globalMap.get("tFileList_1_CURRENT_FILE"))

You can get the current file name using this variable, so, add a new column and set its expression with this variable. 
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: Load file content and filename into database

hi alrond, if all your raw files have similar columns then u could finish yor Job like this:

  



after, doing the above steps dump all this values into thashouput and do the post job as per the below job design:


output will be :

One Star

Re: Load file content and filename into database

thank you Talend team!
the article is about inserting a blob in the database, but how to download a blob from db to a specified filepath?
thanks and regards!
One Star

Re: Load file content and filename into database

nevermind partners!
I found it in ""
One Star

Re: Load file content and filename into database

Thank you so much for posting this.
A question if I may and I apologize if my post is bumping an old thread, but this is really a agood place to finish what I am trying to do.
 The files I am trying to joinn are named in a pattern xxx_yyyy_zzzz and sometimes xxxx_yyyy_zzzz.
All I want to do is except of having the full name is adding the xxx or xxxx before the first underscore. I am aware that all I have to do is change the expression. But I am such a novice and I really apreciate any help.
Thank you.
Community Manager

Re: Load file content and filename into database

Thank you so much for posting this.
A question if I may and I apologize if my post is bumping an old thread, but this is really a a good place to finish what I am trying to do.
 The files I am trying to joinn are named in a pattern xxx_yyyy_zzzz and sometimes xxxx_yyyy_zzzz.
All I want to do is except of having the full name is adding the xxx or xxxx before the first underscore. I am aware that all I have to do is change the expression. But I am such a novice and I really appreciate any help.
Thank you.

Hi  
Can you please describe your requirement with more details in a new topic? I don't understand what you want to do...
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: Load file content and filename into database

the link to the article is not working, can you please correct this?

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog