Skip to main content
Solved

Text file reader

  • September 14, 2014
  • 6 replies
  • 57 views

Hi Everyone,

 

 

I've a little question to ask, How do I read a list of files from a text file (Throught text file reader), which is placed in the parent folder of another data reader in the same workspace.

 

 

I can do it manually, but I want the text file reader to automatically read a certain file from the parent folder. The attributer creater is not willing to expose my created attributes as private/public variable, which i wanted to use as an input to Text file reader.

 

 

Thanks

Best answer by david_r

Hi,

 

 

here's a short Python scripted parameter that will return the parent directory of another published/private parameter:

 

 

---

 

import os.path

 

filename = FME_MacroValues['MY_FILENAME']

 

return os.path.abspath(os.path.join(filename, os.pardir))

 

---

 

 

Assumes that there is a published/private parmeter called MY_FILENAME. The scripted parameter must appear BELOW this parameter in the Navigator pane (i.e. order of execution).

 

 

David
View original
Did this help you find an answer to your question?
<strong>This post is closed to further activity.</strong><br /> It may be a question with a best answer, an implemented idea, or just a post needing no comment.<br /> If you have a follow-up or related question, please <a href="https://community.safe.com/topic/new">post a new question or idea</a>.<br /> If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • September 15, 2014
Hi,

 

 

as you discovered, you cannot set the value of of a private/pubilc attribute from within the workspace, they're effectively read-only as long as the workspace is running.

 

 

Perhaps you should look into Python scripted parameters, where you can write a Python script that calculates this values when the workspace starts, e.g. on the basis of other (static) parameters.

 

 

David

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 15, 2014
Or use a filewriter to write your dynamicaly created attributes after u used attributeexposer on them, then workspacerunner to call filereader.

  • Author
  • September 15, 2014
Hi, 

 

 

I can set the Source Text File (Text file reader) to a Published attribute, the problem lies in getting the parent Folder. I also can do it by using FileNamePart Extracter. Just not able to expose the extracted Features as Public / Private parameters.

 

 

Thanks.

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 15, 2014
If u are talking setting parameters during runtime..that can only be done using phyton or tcl etc. (there is a forumtopic somwhere thiss late june/july somewhere)

 

If u are talking attributes, this can be done using attributeexposer==>featurewriter==>featurereader combo. I have posted a neat script to accomplish this. Or there are some posts using phyton to do same.

david_r
Celebrity
  • Best Answer
  • September 15, 2014
Hi,

 

 

here's a short Python scripted parameter that will return the parent directory of another published/private parameter:

 

 

---

 

import os.path

 

filename = FME_MacroValues['MY_FILENAME']

 

return os.path.abspath(os.path.join(filename, os.pardir))

 

---

 

 

Assumes that there is a published/private parmeter called MY_FILENAME. The scripted parameter must appear BELOW this parameter in the Navigator pane (i.e. order of execution).

 

 

David

  • Author
  • September 16, 2014
Hi,

 

 

Thanks David, by using python script provided by you, I created what I wanted. Thanks a lot.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings