Question

Read a file containing user variables

  • 24 April 2020
  • 2 replies
  • 6 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.

2 replies

Userlevel 2
Badge +12

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.

Badge +22

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.

Reply