CSVからデータを読み取るAppleScriptがあります(成功しました!)。スクリプトでデータの編集が完了したら、変更したテキストをそのファイルに書き戻します。 私のテキストがCSVファイルに書き戻されると、キャリッジリターンがすべて失われるため、1行として読み取られます。私は何が間違っているのですか?
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