I have .prn files which are specific to very niche software. I think the best way to read these into FME is as text files. There are multiple sections of this text_line_data which I want to extract (highlighted in red boxes). The text file also contains a table which i’d like to somehow split into attributes/columns(green section) with the yellow section being a unique ID or each feature.
What is the best way to extract this data from multiple text files in this same format?
Thanks,
Rob
Best answer by geomancer
Thank you for the .prn file, I had a lot of fun parsing it!
I have not found any documentation on the structure of the InfoWorks .prn file, so I just opened the file and went from there.
To be as flexible as possible, I mostly worked with lists in AttributeSplitters, ListExploders and AttributeManagers.
For some reason the line for Node 1 contains tabs of 4 spaces. Not sure why, as the lines for the other nodes only contain spaces.
Also the line containing Link 1 seems to miss a single space, making the values on this line end up one position to the left.
And I wondered whether the positions on the lines were fixed, or maybe could change depending on the length of the values.
In the end my approach differs a bit from what I wrote earlier.
Step 1: Read the file (Whole File At Once), split into parts at ‘**********’
Step 2: From the first part get the Event Name
Step 3: From the third part, get the Node Data
Step 4: From the fifth part get the Link Data
I have attached the workspace (FME 2023.1).
It is not annotated, but I hope you can learn about its workings by studying it.
Find the line starting with ‘Summary results for event”, and get the text you want (substring from a given starting position till the end)
Read the file as text, whole file at once
Keep everything after '******** Node Data *********’
Maybe drop some stuff at the end, below what is shown in the screen dump
Split into features on NewLine
The data is in neat columns, so you can get your attributes with a substring from a certain starting position, and reading a certain number of characters.
Another approach: InfoWorks supports export to CSV.
That may be a much easier solution than trying to parse your .prn file.
@Geomancer, thanks, i’ll give that a go, I’ve saved a sample prn as a text file and uploaded. What transformers would you suggest for extracting the text below node data for example and for splitting it into attributes?
Another approach: InfoWorks supports export to CSV.
That may be a much easier solution than trying to parse your .prn file.
Will also see if this is possible, think the standard sim output is .prn but we’re trying to use HEEDS to automate Infoworks simulations and results exports, I may be able to get that to export csvs.