Closed GalaxieT closed 2 years ago
The cod above seems not compatible. I made some adjustments.
def _fetchRow(dataStr, searchStr, index):
startIndex = dataStr.index(searchStr, index) + len(searchStr)
endline_index = dataStr.index("\n", startIndex)
if "\"" in dataStr[startIndex:endline_index]:
first_quote_index = dataStr.index("\"", startIndex)
looking = True
next_quote_index = dataStr.index("\"", first_quote_index+1)
while looking:
try:
neighbor_letter = dataStr[next_quote_index+1]
if neighbor_letter == "\"":
next_quote_index = dataStr.index("\"", next_quote_index+2)
else:
looking = False
except IndexError:
looking = False
final_quote_index = next_quote_index
word = dataStr[first_quote_index+1:final_quote_index]
word = word.replace("\"\"", "\"")
endIndex = dataStr.index("\n", final_quote_index)
return word, endIndex + 1
else:
endIndex = endline_index
word = dataStr[startIndex:endIndex]
word = word.strip()
return word, endIndex + 1
Hi! Sorry for the bug. I should be able to take a look at this tomorrow. Thanks!
I've just released version 4.3.0. This should have robust support for newlines and quotes. If you have problems with any textgrids please let me know.
I think this issue has been resolved. Is it ok to close?
Sure.
Files like the following:
Only the "zao part is recognized. According to the manual of Praat, string variables are identified by double quotes instead of newlines. (double quotes in text are turned into two double quotes in the file: " → """"![image](https://user-images.githubusercontent.com/52556189/113475448-5bc53700-94a8-11eb-8d36-3dce7d0099c0.png)
It is not hard to fix it, but I'm unfamiliar with git/github. So I paste the changed code in below (in place of original _fetchRow in tgio):
I suppose it might be possible that in other places, like textgrid short version reading and writing, there are also problems due to this issue.