I’ve only just started using AppleScript, so my apologies for what is simple question / problem.
I’m trying to read in a csv file, re-format the text and then output it to a new file.
In the csv file the text fields are enclosed with double quotes and I can’t figure out how to identify them.
repeat with currentLine in inputData
set currentChar to 1
repeat while (length of currentLine > currentChar)
log characters currentChar thru currentChar of currentLine & "\"" -- this shows a character match
if (characters currentChar thru currentChar of currentLine) is "\"" then -- but this never matches
log "never gets to here"
else
log "always ends up here"
end if
set currentChar to currentChar + 1
end repeat
end repeat
I’m obviously doing something really, really stupid but after an hour or so looking at it I can’t figure it out.
characters currentChar thru currentChar of currentLine
is a bit confusing, it returns a list, then the comparison doesn’t work, better is
character currentChar of currentLine
but I would perfer this
repeat with currentLine in inputData
repeat with oneChar in (get characters of currentLine)
log oneChar & "\"" -- this shows a character match
if contents of oneChar is "\"" then -- but this never matches
log "never gets to here"
else
log "always ends up here"
end if
end repeat
end repeat
converting CSV data is a very complicated thing. God luck with it
The logic side of parsing and converting the csv isn’t a problem for me, I’ve done far worse things before. Its just getting used to AppleScript, which isn’t helped by a lack of decent documentation - or at least I haven’t found anything thats helping me much at the moment.
All made worse by me only starting on the work today and promising it will be done for Monday.