0

我正在尝试获取一行 CSV 并从中提取一项,这里有一些代码:

tell application "Finder"
    set workingFile to (open for access outPath)
    set theContents to read workingFile using delimiter {ASCII character 13} as list
end tell

set rowTwo to item 2 of theContents as list
close access workingFile

set AppleScript's text item delimiters to {","}
set rowParts to (every text item in rowTwo) as list

display dialog rowParts

set secondItem to item 2 of rowParts


display dialog "The second item is:  " & secondItem

当程序尝试执行时出现此错误set secondItem to item 2 of rowParts

Result:
error "Can’t get item 2 of {\"Date,Day,Zimmer,Graves,Randolph,Dempsey,Hannah,DeVaughn,,GSA 0034G,GSA 0035G,48' Trailer1,48' Trailer2,53' Trailer\"}." number -1728 from item 2 of {"Date,Day,Zimmer,Graves,Randolph,Dempsey,Hannah,DeVaughn,,GSA 0034G,GSA 0035G,48' Trailer1,48' Trailer2,53' Trailer"}

谁能告诉我为什么会发生这个错误?

4

1 回答 1

0

变量rowTwo必须是字符串,而不是列表,删除as list

as list在其他行是没用的。

set theContents to read outPath using delimiter (ASCII character 13)
set rowTwo to item 2 of theContents
set AppleScript's text item delimiters to ","
set rowParts to text items of rowTwo
set secondItem to item 2 of rowParts
display dialog "The second item is:  " & secondItem
于 2012-07-21T03:45:41.190 回答