Read folder and use the filename for further select querys

Highlighted
Four Stars

Read folder and use the filename for further select querys

Hey there,

 

I need to read a folder to got all pdf-files in there.

The filename need to be splitted, because there are parts in it that I need for my SELECT Statement.
I wanted to do this wich tJAVARow (any better idea?).
First I used "sysout" to show me my filenames. I got the correct rows but always with the same filename (tFileList_1_CURRENT_FILE).

 

tFileList --iterate -- titerateToFlow_1 -- tJavaRow (next planning: -> "query to got other informations and rename the file).

 

Which one is the correct Oracle DB Object? There a a low of it. Is a map necessary?

 

Inputfile: order_123456_2018_12_26.pdf
Output: DB_ROW1#DB_ROW2#AAA#DATE#OLDNAME.pdf

 

 

Thank you


Accepted Solutions
Four Stars

Re: Read folder and use the filename for further select querys

It is finished now \o/

 

Bildschirmfoto 2019-09-18 um 15.12.54.png

- FileList reads the folder context.inputdir

- iterateToFlow change the internal way to work (my guess)

- JavaRow read each filename and extract the information that is needed

- change flow

- DBInput read each line from db with "... and FIELD = "+((Integer)globalMap.get("row2.FIELDNAME"))"

- change flow

- FileCopy rename and move the file if a record was found in database

-- Name: context.inputdir + "/" + (String)globalMap.get("row2.filename")

-- Target-Folder: context.outputdir

-- Filename: (String)globalMap.get("row3.DBFIELD1")+"#"+(String)globalMap.get("row3.DBFIELD2")+"#"+context.GLOBALFIELD3+"#"+(String)globalMap.get("row2.LOCALFIELD4")

## row2.LOCALFIELD4 comes from the javarow (strsplit), there is already the fileextension in it (lucky "error" while working with it).

View solution in original post


All Replies
Twelve Stars

Re: Read folder and use the filename for further select querys

first use tmap in place of tjavaRow (best practices). with lookup on tDBinput
use (tFileList_1_CURRENT_FILEPATH). to get full path of file.

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Four Stars

Re: Read folder and use the filename for further select querys

Thx for Reply.

I used tJavaRow and now I got my values with input_row.NAME and can write it back with output_row.NAME.

But I dont know how to use it for my select statement and I need a way to decide what to do next.
1 row -> rename and move file
0 row -> do something else
Four Stars

Re: Read folder and use the filename for further select querys

I got new ideas and I can debug some variables.
tOracleRow_2_Query has my SQL with a part of the filename.

Now I search a way to got the resultset.
Try n Error and Researching the internet doesn't work jet.
Four Stars

Re: Read folder and use the filename for further select querys

It is finished now \o/

 

Bildschirmfoto 2019-09-18 um 15.12.54.png

- FileList reads the folder context.inputdir

- iterateToFlow change the internal way to work (my guess)

- JavaRow read each filename and extract the information that is needed

- change flow

- DBInput read each line from db with "... and FIELD = "+((Integer)globalMap.get("row2.FIELDNAME"))"

- change flow

- FileCopy rename and move the file if a record was found in database

-- Name: context.inputdir + "/" + (String)globalMap.get("row2.filename")

-- Target-Folder: context.outputdir

-- Filename: (String)globalMap.get("row3.DBFIELD1")+"#"+(String)globalMap.get("row3.DBFIELD2")+"#"+context.GLOBALFIELD3+"#"+(String)globalMap.get("row2.LOCALFIELD4")

## row2.LOCALFIELD4 comes from the javarow (strsplit), there is already the fileextension in it (lucky "error" while working with it).

View solution in original post

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