Skip to main content
Solved

How to retieve data from text file that resides on multiple lines

  • March 24, 2022
  • 5 replies
  • 284 views

Hi,

 

I have a problem extracting data from my text file.

The file looks like this:

******************************************

#Textlimiter=;

#Decimalsign=.

#Provadm

Column1, Column2...ColumnX;

"Value1";"Value2"...""ValueX";

"Value3";""Value4"..."ValueY";

#Provdat

ColumnA, ColumnB...ColumnZ;

"ValueXX","ValueYY"..."Value11";

"ValueQQ","ValueRR"..."Value22";

#End

******************************

The ProvAdm-section can contain one or more rows

The ProvDat section can also conrtain one or more rows

 

I want to read ProvAdm section into one table (SQL Server) and ProvDat into one table (SQL Server) but I dont reaaly understand how to find out where ProvAdm section ends (how many rows should be read) or where ProvData starts (where should I start reading)

 

An additional dimension to the problem is that I need to read multiple files at one go...

 

Perhaps my explanation is not complete but please ask and I will try to explain a little more 🙂

 

//Magnus

Best answer by geomancer

Yet another approach, using  Enable Adjacent Feature Attributes, line numbering from a Counter, TestFilters, AttributeExposers, and some custom List transformers from FME Hub.

Multiline_Text

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

birgit
Influencer
Forum|alt.badge.img+21
  • Influencer
  • 131 replies
  • March 24, 2022

Wow that was way more complicated then I expected but I created an example workbench for you. It splits Provadm and Provdat into two seperate features and then continues on with processing the Provdat part, in the end creating the following result:

2022-03-24_17h38_33Probably not the most elegant solution but it works. You will have to create the Pravadm part yourself but you can reuse some of the transformers used for the Provdat datastream.


Forum|alt.badge.img+2
  • 1891 replies
  • March 24, 2022

@mger1974​ I think I would be tempted to pre-process the text file to create a CSV file for each feature class, then process those csv files. You can take advantage of the Enable Adjacent Feature Attributes in AttributeCreator (under Advanced Attribute Handling) to create a relatively straight forward workspace to do this.

imageI've attached an example workspace (FME 2021.2) based on the sample data created by @birgit​ . This will generate a CSV files for #Provadm & #Provdat that you can then read back in a separate workspace or use the FeatureReader


geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • Best Answer
  • March 28, 2022

Yet another approach, using  Enable Adjacent Feature Attributes, line numbering from a Counter, TestFilters, AttributeExposers, and some custom List transformers from FME Hub.

Multiline_Text


  • Author
  • 1 reply
  • March 28, 2022

Yet another approach, using  Enable Adjacent Feature Attributes, line numbering from a Counter, TestFilters, AttributeExposers, and some custom List transformers from FME Hub.

Multiline_Text

Thank you @geomancer​, this did the trick. It also works if I run multiple files at the same time.

 

Thanks a lot!! 😀

 

Regards

Magnus


geomancer
Evangelist
Forum|alt.badge.img+58
  • Evangelist
  • 932 replies
  • March 28, 2022

Yet another approach, using  Enable Adjacent Feature Attributes, line numbering from a Counter, TestFilters, AttributeExposers, and some custom List transformers from FME Hub.

Multiline_Text

Hi @mger1974​ , thanks for the feedback, good to know it works.

Glad I could help you!