I am learning Talend Open studio. I want to implement the scenario where a row converts into 3 rows. My Source is like
Col1 Col2 Col3
a b c
I want to get the output like below
Col
a
b
c
I have used tcolumntopivotdelimited but failed.
Here is the solution :
In your tmap you need to concat with a ";" for example and normalize the resulted column with the good delimiter
Related
col1=LEFT([col2], CHARINDEX('_', [col2]) - 1)
I am trying to join on columns and I should match col1 data equal to col2 data, but in col2 it should check the characters before the delimiter value '_'
What can I use in the join condition instead on Charindex in Tableau, as this is not supported by Tableau.
col1
abc
dcb
col2
abc_123
dcb_123
You can define a calculated field to use in your joins. The split() function is available and is designed for exactly this purpose. That is you can use split() to obtain the substring before the underscore, which you can use a join key
I have similar question in input csv file. I’m currently loading data from csv file to DB. Getting wrong data in target table not sure how to ignore commas
I have below input
Col1,col2,col3
1,2,3,4
Output should be populated as
Col1 col2 col3 col4
1 2 3 ,4
3,4 should be populated in col3
Instead I’m getting data like below. It has not populated like above. Can someone please help me.Not sure how to do it in Talend.
Col1 col2 col3 col4
1 2 3 4
3,4 data was not populating in same column not sure how to ignore ,comma for 3 and 4
Use Text enclosure character in source file
Col1,col2,col3
"1","2","3,4"
You may also use different escape characters or even delimiter. see "CSV Options" in Component tFileInputDelimited
I'm using postgresql here
Here's a field in my table "num":
adsh: some numeric with dash eg.(1234-23456-456789)
tag: character eg.(ReturnOnAsset)
version: can be one of two format 1. exactly same as adsh 2. us-gaap/yyyy eg. (us-gaap/2009)
there are some other column but not important
primary key is the 3 column above and some other column combine.
for each adsh, there's several version value us-gaap/dei/invest + yyyy or
Also keep in mind that there's 10^8 tuples in this table
step one: select tag, version from num where version=adsh as result a
step two: select adsh, version from num where version!=adsh as result b
step three: select tag, b.version from a, b where a.version=b.adsh
I wonder if I can save the first two steps' result temporarily for in order to do the third step. Can I do that. What's the most efficient way to do this?
Thanks!
I have found the solution using with clause:
with a as (select tag, version from num where version=adsh), b as (select adsh, version from num where version!=adsh) select tag, b.version from a, b where a.version=b.adsh;
Somehow, I can only find examples that show how to add one column.
So I have written this code, which works, but I know there is a much better way to do this:
table t already exists with columns filled with data, and I need to add new columns that are initially null.
t: update column1:` from t;
t: update column2:` from t;
t: update column3:` from t;
t: update column4:` from t;
I tried making it a function:
colNames:`column1`column2`column3`column4;
t:{update x:` from t}each colNamesList;
But this only added one column and called it x.
Any suggestions to improve this code will be greatly appreciated. I have to add a lot more than just 4 columns and my code is very long because of this. Thank you!
Various ways to achieve this....
q)newcols:`col3`col4;
q)#[tab;newcols;:;`]
col1 col2 col3 col4
-------------------
a 1
b 2
c 3
Can also specify different types
q)#[tab;newcols;:;(`;0N)]
col1 col2 col3 col4
-------------------
a 1
b 2
c 3
Or do a functional update
q)![`tab;();0b;newcols!count[newcols]#enlist (),`]
`tab
How can I split a column value into two values in the output? I need have the numerals in one column and the alphabet in the other.
For Example 1
Existing
Column
========
678J
2345K
I need the output to be:
Column 1 Column 2
======== ========
678 J
2345 K
The existing column can have 4 or 5 characters, as shown in the example. There is no space.
Thanks in advance!!
You could convert all letters to spaces & strip them away, then do the opposite with digits in the other column:
SELECT trim(translate(mycol,repeat(' ',26),'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) as col1,
trim(translate(mycol,repeat(' ',10),'0123456789')) as col2
FROM mytable
Adjust as necessary to translate additional characters.
I am not sure about the performance of WarrenT's solution, but it looks like very heavy solution. It does what it is supposed to be doing with little constraints on the the data. If you know more about the data, you can optimize.
String always ends with 1 and only one letter
select left(mycol, length(mycol)-1), right(mycol,1) from mytable