我有一个从 CSV 读取数据的小程序(成功!)。在我的脚本完成数据编辑后,我希望它将修改后的文本写回该文件。 当我的文本被写回 CSV 文件时,它丢失了所有的回车符,所以它读为一行。我究竟做错了什么?
set theFile to choose file with prompt "Select a text file:"
set theFileContents to read theFile
...
set theList to paragraphs of theFileContents
repeat with i from 2 to count theList
set AppleScript's text item delimiters to ","
set theLine to theList's item i
theLine
set clinic_id to first text item of theLine
....
set AppleScript's text item delimiters to ""
...
open for access theFile with write permission
set theData to theList as text
write the [theData] to theFile as text
close access theFile
display dialog the [theLine]
end if
end repeat
有什么建议么?这段代码的输出是:
1,2,3,A,B,C,X,Y,Z
当我想要的是
1,2,3
A,B,C
X,Y,Z