I have csv data file as below:
`Column1` `Column2` `Column3`
{'name':'Steve Jobs'} , {'first_name':'Steve'} , {'last_name':'Jobs'}
{'name':'Mark Zuckerberg'} , {'first_name':'Mark'} , {'last_name':'Zuckerberg'}
{'name':'Steve Jobs'} , {'first_name':'Steve'} , {'last_name':'Jobs'}
I want my data as below using Talend Tool:
`name` `first_name` `last_name`
Steve Jobs Steve Jobs
Mark Zuckerberg Mark Zuckerberg
Steve Jobs Steve Jobs
You can use substring()
and indexOf()
functions to achieve this.
Explanation:
:
we can substring after the :
and before }
:
and }
, we can use indexOf
functionBelow is the condition used in tMap for three columns,
row1.Column1.substring(row1.Column1.indexOf(":")+2, row1.Column1.indexOf("}")-1)
row1.Column2.substring(row1.Column2.indexOf(":")+2, row1.Column2.indexOf("}")-1)
row1.Column3.substring(row1.Column3.indexOf(":")+2, row1.Column3.indexOf("}")-1)
Result,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.