I have csv file like
col_1, col_2, col_3, col_4, col_5, col_6
mno," "," "," ","0","0",abc
In Talend TOS, while reading this csv file, HOW CAN DO FOLLOWING
1. convert the cols where there is no value like ,,, to -> NULL and insert to DB
2. convert the cols where there is only qoutes like "","","" to -> NULL and insert to DB
Solved! Go to Solution.
Prepare your job flow like this -
tFileInputDelimited- > main - > tMap - > main -> tDbOutput (the respective db output component as per your use-case)
In tMap you need to search for replace the values for each of your input columns, like this -
row42.col_2.isEmpty()? null : row42.col_2
(row42.col_3.startsWith("\"") && row42.col_3.endsWith("\"")) ? null : row42.col_3
the above code is simply looking for any blank string (no value) and making it null.
The next one is searching for quotes ("") and making it null - to be double sure you could also check for the length (length = 2) in case if any input column has double quotes to start and end with.
Also in your tMap output do remember to make your output columns as nullable.
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Part 2 of a series on Context Variables
Learn how to do cool things with Context Variables
Find out how to migrate from one database to another using the Dynamic schema