Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
kdv
Contributor
Contributor

Specifying filepath in a config file that is deployed with the project

Hi there

I have a fairly standard job that reads in data from several files, does some transformations and outputs a file.  It is all working as it should on my local machine as I define the filepath as absolute paths.

 

However, I will deploy the project on a server over which I don't have control over the file structure.  I would therefore like to create something along the lines of a key-value config/properties file that is packaged with the project.  When it is deployed, the variables can be updated to reflect the deployed environment by opening the config file in a text editor, making the changes and saving it.  Obviously these variables will need to be read into the job at runtime.

 

I've read a bit about contexts, but those seem to be defined within the project itself and therefore somebody wouldn't be able to edit the info in there at any time.  If they need to change, I would have to make the changes to the context in Talend Studio, build and redeploy.  Rather than just opening a text file, making some changes and saving it again.  

 

I assume this is possible.  Any pointers in the right direction would be appreciated.

 

Thanks

Labels (3)
2 Replies
TRF
Champion II
Champion II

You can change value of context variables at any time by editing the properties file associated to the desired context.
You can also choose to store the context variables into a specific file (outside from the standard context folder) or into a database.
Thank's to the "--context_param" parameter, you may also pass the value on the command line.
As you can see, you have the choice with context variables and don't have to return into the Studio to change their value.
Just refer to the documentation.
Anonymous
Not applicable

yes! it is very much possible. You can place a files in the unix box and store the content as key-value pair with a field delimiter. The key should exactly same as that of your context variable defined in the job.

 

 

Content of the file:

DataFilePath=/home/talend/data/

FileName=customer.csv

LogFilePath=home/talend/log

 

In the Job,

 

1. Use tInputFileDelimiter component.  Provide the absolute file path and file name. Give "=" as the field delimiter and define the schema as string for both key and value fields.

2. Use tContextLoad to load the key value pair. 

 

By this way the value form a file is assigned to context variable during run time.

 

If you dont want to follow this approach, please follow the suggestions given by TRF. The context variables defined in any talend job is embedded in a property file. when you build the job, along with the wrapper .sh and jar files,  there will be a folder named similar to your project name. Under that folder there will be .property files ( by default it would be Default.property) with context variables and its defined values.

 

Hope this helps!

 

Regards,

Ragu