• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to create file from a list from a DB

#1 2008-10-13 18:08:34

nicolasdiogo
Member
Company: BrainPowered - BI Services UK
Registered: 2006-11-24
Posts: 380
Website

how to create file from a list from a DB

hi folks,

i have a list of file names that need to be created and populated from a DB.
the source table is like this:

create table tb_fileListed(

filename varchar( 200 ),
recordType char(8),
recordContent varchar(4000)

)

at first i need to check if a file already exsts, and if not then create one.

my requirement is to place all files into a defined folder, this is defined as a variable in my job <baseFolder>.

i have created a mysql input to retrieve the dataset from the db, and connected to a tFolwToIterate.
and i thought that i would be able to connect to a tFileExists and then tFileTouch but i can not work out how to set the value for the file path since they only accept variables.

i suppose i can not see how to send the values from the row into a variable for each value.

i am sure this is something simple that i am missing out.

thanks,


Nicolas

Offline

#2 2008-10-13 22:05:37

Volker Brehm
Member
Registered: 2007-04-03
Posts: 1139
Website

Re: how to create file from a list from a DB

Hi Nicolas,

the examples are for java:

You can retrieve the actual row (of tFlowToIterate) with the following syntax (in this example the connection to tFlowToIterate is named row1):

Code:

globalMap.get("row1.filename")

To handle the folder you should define a context variable and create the filename as follows:

Code:

globalMap.get("row1.filename") + "/" + context.folder

Bye
Volker

Offline

#3 2008-10-14 00:02:59

nicolasdiogo
Member
Company: BrainPowered - BI Services UK
Registered: 2006-11-24
Posts: 380
Website

Re: how to create file from a list from a DB

hi volker,

i have created this job to understand your explanation.
but i can not receive any value for globalMap.get("row1.filename").

please have a look at the screenshot to see what i am missing.

i am trying to get the correct result in a message box at this point.


thanks,


Nicolas


Uploaded Images

Offline

#4 2008-10-14 22:21:33

Volker Brehm
Member
Registered: 2007-04-03
Posts: 1139
Website

Re: how to create file from a list from a DB

Hi,

in your case use row2. The name of the key depends on the name of the input flow into tFlowToIterate.

Bye
Volker

Offline

#5 2008-10-14 23:24:07

nicolasdiogo
Member
Company: BrainPowered - BI Services UK
Registered: 2006-11-24
Posts: 380
Website

Re: how to create file from a list from a DB

many thanks,

Volker it worked just fine.

i did have a minor glitch, as i had to cast it as a string:

globalMap.get("row2.fileName").toString();

just so i do not need to disturb you with these simple question.

where do you find information about this type of classes of Talend? globalMap ??

i did check the documentation and could not find it anywhere.


Nicolas

Offline

#6 2008-10-15 00:11:40

Volker Brehm
Member
Registered: 2007-04-03
Posts: 1139
Website

Re: how to create file from a list from a DB

Hi Nicolas,

yes you have to use toString() or cast the result. The hash is based on Object (i think).

To get more information about this you should read the code (as I have done).

There is no specific documentation about this (as I know).

Bye
Volker

Offline

#7 2008-10-15 00:35:56

nicolasdiogo
Member
Company: BrainPowered - BI Services UK
Registered: 2006-11-24
Posts: 380
Website

Re: how to create file from a list from a DB

thanks

Offline

#8 2008-10-15 13:48:49

nicolasdiogo
Member
Company: BrainPowered - BI Services UK
Registered: 2006-11-24
Posts: 380
Website

Re: how to create file from a list from a DB

just for reference
it can be done in a different way:

row generator
=>
tMap (manipulate rows)
=>
tJavaRow( set a variable with the value of a row [context.CURRENT_FILE = input_row.filename;]
=>
tFlowToIterate
=>
tTouchFile

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » how to create file from a list from a DB

Board footer

Powered by FluxBB