1

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

badner
  • 768
  • 2
  • 10
  • 31

2 Answers2

2

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.

Stefano
  • 1,405
  • 11
  • 21
0

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$)
jja
  • 2,058
  • 14
  • 27