2
CSVからデータを読み込むためのアプリスクリプトがあります(正常に!)。スクリプトのデータの編集が終わったら、変更したテキストをそのファイルに書き戻したい。 私のテキストがCSVファイルに書き戻されると、キャリッジリターンがすべて失われてしまい、1行で読み上げられます。私は間違って何をしていますか?Applescriptを使って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
私が誤解していない場合、 'theList'変数は元のファイルのすべての段落(行)をリストとして保持しているため、ループ*内のファイル*に書き込むと、ファイルの*あなたが行を持っていることが何回もあります。おそらく、 'end repeat' *の後にファイル*に書き込むほうが理にかなっていますか? – fanaugen