02.12.2012 19:30:00 • Categories: Applescript • Tags: Applescript
AppleScript: parsing a csv file
property theCSVFilename : "/Users/username/Desktop/example.csv" property theCSVDelimiter : ";"on readAndParseCSVData() -- open csv file set csvRows to read file theFile using delimiter {return}
-- Parsing the information set parsedArray to {}
copy the text item delimiters to OldDelims set the text item delimiters to theCSVDelimiter
repeat with csvLine in csvRows --tell application "Automator" --set end of parsedArray to call method "componentsSeparatedByString:" of csvLine with parameter theCSVDelimiter --end tell set end of parsedArray to (text items of csvLine) end repeat
set the text item delimiters to OldDelims
return parsedArray end readAndParseCSVData