Read File component

This issue has been solved. See solution.
billyccfs's picture

I'm having trouble getting the string data from a text file. I have a text file that I am trying to read the first line from (the only text in there, actually). I can't seem to figure out how to get that line into a single string variable.

Any help is appreciated.

yliquor's picture

ByteArrayToText

Solution

 I used the IO. Read File component to read it in, then EncodingComponents.ByteArrayToText  component to change to a string.
Have you tried that?

billyccfs's picture

Sweet

That worked perfect!

thanks.

ChrisBern's picture

For others' benefit in the future...

...once you do what yliquor suggested, you'll have the entire contents of the file in a text variable.  From that point on, there are several components in the Text Handling category which you could use to manipulate the text in your variable. 

For example, Split Text Into Collection would split the text into a collection (array) of elements where each element is (if you use the Newline delimiter) one line of the text file...then you could use components in the Collection Handling category to work with your new array. 

Or, you could use the Strip, Trim, Pad, etc. components to parse the text variable or drill into it further. 

The idea, though, is that once you get the file contents into a text variable, then it's just another variable in your process stream which contains data that you can manipulate further to meet your needs in your project.