Extract values as collection from text that has lines and spaces

YGC

New Member
Hi everyone,

I've been trying for a several time to extract specific values from a text file and put in into a collection, so i can work with the data. Next i show how is my text file is received:
-This text has always de same structure.
-I don't need the header at the begging of each page

What i need is to be able to extract fields and values of each line when the data starts in a collection like attached file "Collection - Fields I need" and "Values I need"
-I've already tried split each line of the text and then use regex values such as (?<=.)(\b\w+\b) to get data that i need from text.

Thank you in advance
 

Attachments

  • exportedtext.txt
    16.5 KB · Views: 34
  • Collection - Fields I need.PNG
    7.6 KB · Views: 30
  • Values i Need.PNG
    4.9 KB · Views: 31

gil.silva

Active Member
Hello YGC,

I believe the following pattern does what you need: (\d{10}).*?(\d{2} \d{4} \d{4} \d{8}).*?(\d{8}).*?(\d{6}).*?(\d{6}).*?(\w).*?(\w).*?(\S+).*?(\D{5,48})
Keep in mind that you need to use a proper object to extract the regex as collection, where each column will give you the correct parameter.


Please check the screenshot with the results.
 

Attachments

  • regex.png
    66 KB · Views: 36
  • Like
Reactions: YGC

YGC

New Member
Hello YGC,

I believe the following pattern does what you need: (\d{10}).*?(\d{2} \d{4} \d{4} \d{8}).*?(\d{8}).*?(\d{6}).*?(\d{6}).*?(\w).*?(\w).*?(\S+).*?(\D{5,48})
Keep in mind that you need to use a proper object to extract the regex as collection, where each column will give you the correct parameter.


Please check the screenshot with the results.



Hi gil.Silva,

Amazing, that's going to solve my problem, thank you very much really.

In some cases (for example line 3 of the values in the exported text, only the last 2 columns have values., being the others in blank. I don't think regex values can achieve this is there anyway to extract the datable with those types of lines too?


Thank you,

ygc
 
Top