Read file path from a csv file(key-value pair) to context variable

Highlighted
Four Stars

Read file path from a csv file(key-value pair) to context variable

Hi Forum,
How can I dynamically read file path to context variables ?
My job design is as follows 
CSV file -> Context Load -> LogRow
context variable created for file path is : file_to_path 
CSV file is located at : C:\Users\sadakar.pochampalli\Downloads\context.csv
My goal is to load the database connections defined in CSV file as context variables so that I can make the job dynamic. 
( I used TOS 4 years back for few months only and now would be working on a project) - I have found few articles but it doesn't have relative path reading )
Thank you in advance for any inputs. 
Regards,
Sadakar Pochampalli 
Highlighted
Nine Stars
Nine Stars

Re: Read file path from a csv file(key-value pair) to context variable

I am not sure if I understand your problem. Do you want to have a relative file path in a context variable (like "../../context.csv")? If yes, this will be difficult to achieve as the job could be placed and started from anywhere on your file system. I have always only worked with absolute paths for which I also created context variables (in your case "C:/Users/sadakar.pochampalli/Downloads/").
Highlighted
Forteen Stars

Re: Read file path from a csv file(key-value pair) to context variable

Relative path like ./context.csv - work fine
for avoid problems with different locations, You can use next (I personally do this)
In each Job I import global context which include usually only few settings, like:
- context_file_path, and it different for different context groups
if for example DEV it is Studio - fixed path to context file on You developer machine
if it PROD - ./context.csv - it mean file locate in same folder with .sh/.bat file of Your Job
-----------

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 2

Part 2 of a series on Context Variables

Blog

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