ASTID & "return" character ASCII

I am trying to parse data from a text report generated by a piece of software called semaphore. It is more or less a CSV file however there is no comma after the last item before the line break which is attaching the last item of line 1 and the first item of line 2.

Is there any way to set the ASTID to “return” and replace with 'comma" then do a second ASTID to parse the data between each comma?

here is what the text file looks like:

“Alert Type”,“Start Frame”,“Time Code”,“DirectShow Time”,“Total Frames”
2,0,00:00:00:00,0,83456
3,5304,00:02:56:24,1769760000,118
3,5422,00:03:00:22,1809140000,116
3,5552,00:03:05:02,1852510000,148
3,6321,00:03:30:21,2109100000,93
3,28413,00:15:47:03,9480470000,110
3,69165,00:38:25:15,23078050000,120

You can try using something like this:

set dataFile to choose file with prompt "Please select the text file."
set findReplaceList to read dataFile using delimiter (ASCII character 10)
log findReplaceList
set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}

repeat with i from 1 to count of findReplaceList
	set item i of findReplaceList to every text item of item i of findReplaceList
end repeat
set AppleScript's text item delimiters to ASTID
return findReplaceList

ASCII character 10 should be the return you are looking for which will give you a list of the items on each line. The repeat loop will create a nested list for each item from the comma separated items on the line. The returned list should look like this:

Where the first item in the list is a nested list of the column titles, shown here with the parens escaped.

That works pretty well however there is still a return character attached to the last value of each list.
I am making a new text file with these last values and would prefer if the return character wasn’t included in the result.

thanks
-alex

Hi.

Change this line in Jerome’s script:

set findReplaceList to read dataFile using delimiter (ASCII character 10)

. to this:

set findReplaceList to paragraphs of (read dataFile)

Then you don’t have to second-guess what line endings have been used in the file. AppleScript takes care of them for you.