You are viewing limited content. For full access, please sign in.

Question

Question

QF Pattern Match for multiple lines as well as multiple columns of values

asked on March 13, 2014

Hi,

 

I have the following text that I am trying to extract data from:

 

METER NUMBER    PREV.READING       CURR.READING     DIFFERENCE      CONSTANT      CONSUMPTION   I     FAX NUMBER
     157414           2126.0000        2194.0000        68.0000         1.0000         68.0000
     98940           3419.0000        3442.0000        23.0000         1.0000         23.0000
     191480             11.0000          11.0000         0.0000         1.0000          0.0000
    TOTAL ENERGY CONSUMED FOR BILLING PERIOD(kWh)                          91.00

 

My challenge is that I have these 3 MultiValue fields I need to capture:

 

Meter Number

Prev Reading

Current Reading

 

The results should read as follows:

Meter Number

 157414

 98940

 191480

Prev Reading

2126.0000

3419.0000

11.0000

Current Reading

2194.0000

3442.0000

11.0000

 

I am not having any success and have tried so many different variations of regular expressions, I don't know if I should even post them here, it may just be too embarrassing smiley

 

Any guidance would be appreciated.

 

Thanks

Sheldon

0 0

Answer

SELECTED ANSWER
replied on March 18, 2014

Each row of numbers breaks down to a pattern like this (numbers and spaces):

 

[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\n

Use parenthesis to specify the group you want and set pattern matching to "all matches as a multi-value token".

First column:

([\d\.]+)\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\n

Second column:

[\d\.]+\s+([\d\.]+)\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\s+[\d\.]+\n

etc.

2 0

Replies

replied on March 19, 2014

Miruna's solution is A1 (as usual ;-)

 

To adapt for a variable (or high) number of columns, you may want to:

 

> Pattern match each line into a token through activity «Pattern Matching» w/option All matches (as a multi-value token)

 

> Pattern match each of the value above with Miruna's expression [\d\.]+ into another multi-value token through activity «Pattern Matching» w/same option

 

> Now you can iterate over each numeric value

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.