Skip to main content
Solved

Text string from file using FeatureReader Transformer


garyb
Contributor
Forum|alt.badge.img+5
  • Contributor

I have a "Directory and File Pathnames" reader that gives me a list of text files in a Windows folder. I want to pass those folder and filenames to a FeatureReader transformer and be able to read the text lines from them as output for further processing, but I can't seem to get anything out of the FeatureReader other than the results of the Directory and File Pathnames that go into it. How do I get the contents of the text files out?

Best answer by daveatsafe

garyb wrote:

The screenshot I provided is all there is. There is no text_line_data attribute to the right.

 

I changed the Attribute handling to 'Only Use Result' as you suggested. I ended up with 2300 rows with no schema.

 

image

Try clicking on one of the rows, then examine the Feature Information window to see all the attributes. It may be that the text_line_data attribute is not exposed on the Generic output, but it will still be read. You can use an AttributeExposer transformer to expose it.

View original
Did this help you find an answer to your question?

8 replies

daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • January 22, 2024

Hi @garyb​,

In the FeatureReader Parameters, set the Format to Text File and the Dataset to the attribute path_windows. This will read the lines from all the text files in the target folder.


garyb
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 22, 2024

Thanks Dave, but that's exactly what I've been trying to do without any luck.

 

My text file has 2300 rows in it, and the output from the FeatureReader also has 2300 rows in it, but they are not the contents of the text file, they're all identical and match the input coming from the Directory and File Pathnames reader.


garyb
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 22, 2024

image.png


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • January 22, 2024
garyb wrote:

Thanks Dave, but that's exactly what I've been trying to do without any luck.

 

My text file has 2300 rows in it, and the output from the FeatureReader also has 2300 rows in it, but they are not the contents of the text file, they're all identical and match the input coming from the Directory and File Pathnames reader.

The contents of the text files will be in an attribute named text_line_data. You may need to scroll right to see it. The other attributes are from the trigger feature. You may want to change the setting in the FeatureReader - Attribute and Geometry Handling - Accumulation Mode to 'Only Use Result' in order to avoid collecting all the extra attributes.


garyb
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 22, 2024

The screenshot I provided is all there is. There is no text_line_data attribute to the right.

 

I changed the Attribute handling to 'Only Use Result' as you suggested. I ended up with 2300 rows with no schema.

 

image


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • Best Answer
  • January 23, 2024
garyb wrote:

The screenshot I provided is all there is. There is no text_line_data attribute to the right.

 

I changed the Attribute handling to 'Only Use Result' as you suggested. I ended up with 2300 rows with no schema.

 

image

Try clicking on one of the rows, then examine the Feature Information window to see all the attributes. It may be that the text_line_data attribute is not exposed on the Generic output, but it will still be read. You can use an AttributeExposer transformer to expose it.


garyb
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 23, 2024

I think I have it now. I added 'text'line'data' as an attribute to expose under the <generic> Port, and they look like they're coming through now.

Thanks for the hint.


garyb
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • January 23, 2024

Yes, our messages passed each other, but I've got it now. Thanks for your help.


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