badner
badner

Reputation: 818

load text from .txt into praat info window

I would like to read the information from a text file in the praat window. I can "echo" text to the window with:

writeInfoLine: "Hello World"
appendInfoLine: "Goodbye"

But what I don't know how to do is to do the same thing if I have

"Hello World"
"Goodbye"

saved to a simple .txt file

I want to load the content of this file into the Praat Info window and save it to another .txt

Upvotes: 1

Views: 582

Answers (2)

jja
jja

Reputation: 2098

Other than for debugging, there are in general 0 reasons to use the Info window.

In this case, if what you want is to copy the contents from one file to another using Praat, you could use readFile() and writeFile():

writeFile: target$, readFile$(source$)

If, on the other hand, what you want is to dump the text file to the Info window, you don't need to loop through the Strings object:

writeInfo: readFile$(source$)

Upvotes: 0

Stefano
Stefano

Reputation: 1485

You can read plain text into a Strings object and then manipulate the strings depending on your needs.

Read Strings from raw text file: "text.txt"
numberOfStrings = Get number of strings

for stringNumber from 1 to numberOfStrings
     string$ = Get string: stringNumber
     appendInfoLine: string$
endfor

You can use appenFileLine: "output.txt", string$ to write to a text file.

Upvotes: 2

Related Questions