Extract data from TXT file


This TXT is generated from a memory calculation software where the number of lines can vary.

The challenge is to save items that are marked in yellow in a variable.

I appreciate the personal help.

input.txt (152.5 KB)

You will have to loop over the lines and check if it contains the info you need, then extract it with string operations.

@eniosoeiro - You can use Regex to extract the data you are looking for…

StrMAWP = system.text.regularexpressions.regex.match(Inputtxtstring,"(?<=Maximum Allowable Working Pressure\s+)[\d.,]+").value

StrEMAWp = system.text.regularexpressions.regex.match(Inputtxtstring,"(?<=External Max. Allowable Working Pressure\s+)[\d.,]+").value

StrHTP = system.text.regularexpressions.regex.match(Inputtxtstring,"(?<=Hydrostatic Test Pressure\s+)[\d.,]+").value

StrFlgB = system.text.regularexpressions.regex.match(Inputtxtstring,"(?<=Flg Bolting\s+\|\s+).*?(?=\|)").value

Hope this helps…


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.