Skip to main content
Inspiring
Oct 26, 2011 11:11 PM UTC
Answered

Read a .txt file

I'm trying to find out how to read a .txt file and simply assign its contents to a variable. Is this possible?

 

[Edit] Right after posting I found this page which seems like it might be in the direction I want to go but I haven't checked it out completely yet: Read Tab Delimited Text File

Just posting the link for future searchers or if anyone will tell me 'Hey! That's not what you're looking for!'

This topic is closed to new replies. Start a new post to keep the conversation going.
crydrkCorrect answer
Inspiring
Oct 27, 2011 2:16 AM UTC

For anyone interested, the simplified answer for me was:

var fileToParse = File ('path');

fileToParse.open('r');

var dataToGet = fileToParse.readln();

fileToParse.close();

I only needed the one line, so thats why my example above is so simple.

2 replies

crydrkAuthorCorrect answer
Inspiring
Oct 27, 2011 2:16 AM UTC

For anyone interested, the simplified answer for me was:

var fileToParse = File ('path');

fileToParse.open('r');

var dataToGet = fileToParse.readln();

fileToParse.close();

I only needed the one line, so thats why my example above is so simple.

Translate
Known Participant
Jul 22, 2022 6:41 PM UTC

What should you do if you need more than one line?

Translate