Hi everyone,
I have a text file which I want to convert to a list and delimit by (ascii character 10 not followed by ascii character 32)… In other words, the text file has LF characters followed by spaces, and then LF characters not followed by spaces. The LF without the space is where I want the list items to be broken up.
The text file is rather long, so I am wondering if there is an easy way to do this without scanning each and every character of the file as I am doing here:
set thefile to (path to desktop as string) & "addressbook"
set fileid to open for access file thefile
set contentlist to read fileid
close access fileid
set thechars to characters of contentlist
set thelist to {}
set x to 0
set y to 1
repeat with currentchar in thechars
set x to x + 1
try
if item x of thechars = (ASCII character (10)) and item (x + 1) of thechars ≠(ASCII character (32)) then
set AppleScript's text item delimiters to ""
set end of thelist to ((items y thru (x - 1) of thechars) as string)
set y to x + 1
end if
end try
end repeat
return thelist
as you can imagine… this script takes forever to run…
thank you for your time.