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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Writing regular expression in tmap

Hi all,

 

How to write regular expression in tmap.

 

Source column data.

02 04OCT 10:48:16 220001 .

 

Output:

col1  col2      col3      col4

02,  04OCT,  10:48:16, 220001

 

Thanks

Shree

Labels (2)
20 Replies
Anonymous
Not applicable
Author

Hi @Chirgal,

 

I have tested problem is, the source is coming with single space and multiple space.

So it create mutiple columns unnecessary and some records moving next columns.

 

Ex: 

input:

colun1

12 <space>

13 <space><space>  26

 

output:

colu1      col2           col3          col4

12        <space>

13        <space>      <space>           26

 

Thanks

Shree

Anonymous
Not applicable
Author

Hi @Chirgal

 

Any idea on how to over come on issue with multiple space.

 

Thanks

Shree

Anonymous
Not applicable
Author

Let's try to replace multiple spaces on source:

Try this:

Source_col.trim().replaceAll("\\s+", "\\s");
Anonymous
Not applicable
Author

Hi @Chirgal,

 

Records are inserting whole column names into single columns.

 

I am attaching screen shot for references.  Kindly help me on this we are near to close issue.

 

Thanks

Shree


2.PNG
1.PNG
Anonymous
Not applicable
Author

First try to read whole line into single column using TfileInputFullRow.

Then use tmap to replace multiple space to single space. Source_col.trim().replaceAll("\\s+", "\\s");

After that use TExtractDelimitedFields to split the column based on space to multiple columns.

 

Got some idea?

Sorry. I don't have access to studio. Cant attach job or snaps

 

 

Anonymous
Not applicable
Author

Hi @Chirgal,

 

Sure,  TfileInputFullRow ----> tmap --> tfileoutputfiledelimited.

 

I am getting values multiple space and single space with "s".

 

Ex:

colu:

02 24OCT 10:57:37

 

Output:

02s24OCTs10:57:37s4246899014

 

How to replace "s" wiht space or any other delimiter. Before jumping to TExtractDelimitedFields.

 

Or, using TExtractDelimitedFields  it will handle "s" values between fileds?

 

 

Thanks

Shree

Anonymous
Not applicable
Author

No need to replace. In textractdelimetedfields, use s as delimetre. It will separate column based on s
Anonymous
Not applicable
Author

Hi @Chirgal,

 

Everything is fine, challenge i am facing column issue. Please check below example.

 

Ex: Source data

 

12 <space> 03oct <space>13:21:21  <space>             <space>    121212 ...

13 <space> 05oct  <space>12:2:11    <space>   0101  <space> 121212 ...

 

Intermediate result after removing multiple space.

colum1:

12s03octs13:21:21s121212s...

13s05octs12:2:11s0101s121212s...

 

Current output am getting

col0   col1        col2         col3 ..     col4

12     03oct     13:21:21    121212  ...

13     05oct     12:2:11        0101    121212 ...

 

Expected ouptut

col0   col1         col2      col3        col4

12     03oct   13:21:21                  121212 ...

13     05oct   12:2:11       0101     121212 ...

 

Thanks

Shree

Anonymous
Not applicable
Author

Can you check, if source columns are of fixed width?
Are column starting positions are always same in source file??
Anonymous
Not applicable
Author

Hi Chirgal,

 

No, If you ask me  length of the columns is fixed: No,

 

i am tried with regex and positional file. it not working as expecting.

 

Same issue with <space>

 

Thanks

Shree