Skip to main content
Question

Read a file containing user variables

  • April 24, 2020
  • 2 replies
  • 43 views

I'd like to read a text file containing several lines of user defined variables given in the following format:

var_name = "var value"

There are many lines, each one contains one single variable with one single value:

var_name0 = "var value0"
var_name1 = "var value1"
...

 

I read the text file using an AttributeFileReader to which I connected an AttributeSplitter.

 

My results come as one single concatenated line which is obviously not what I want.

 

 

In the Delimiter field of the latter, I tried inserting `\n` `\r` or`\r\n` without any success.

 

0684Q00000ArDSRQA3.png

 

I also tried inserting a single newline by pressing one time enter in the "Editor" as discussed here (2013):

 

https://knowledge.safe.com/questions/2361/use-attributesplitter-with-a-carriage-return.html without much success.

 

 

I'm using FME(R) 2020.0.0.1 (20200316 - Build 20202 - linux-x64) on Ubuntu 18.04.

 

Thanks.
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.

2 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • April 24, 2020

I would try reading the file line by line.

Then pick each line apart, setting the attribute name and attribute value, using AttributeSplitter, delimited by '='.

Finally using Aggregator to get all attributes in one feature.

Hope this helps.


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • April 24, 2020

What @eric_jan said, though I would probably create an attribute from the results of the attribute splitter before aggregating.

 

 

That said, if you have any control over the user variable file, making it a CSV would be easier to work with directly in FME.