Transforming a TXT file in a list, getting wrong

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-06T15:04:55Z Indexed on 2010/05/06 15:08 UTC
Read the original article Hit count: 156

Filed under:

I have a txt plain file that has a list of numbers. One number per line, like:

978-972-722-649-8
978-972-722-646-7
978-972-722-627-6
978-972-722-625-2
978-972-722-594-1

etc.

This list is on a file called file.txt, was created and saved on TextEdit using Western (ISO Latin 1) encoding.

Now I am trying to use Applescript to read this file and transform it on a list.

I have this script

set myDirectory to path to desktop folder as string
set myFile to myDirectory & "file.txt"

try
    set open_file to ¬
        open for access file myFile without write permission
    set myList to read open_file using delimiter return
    close access open_file
on error
    try
        close access file open_file
    end try
end try

after running this script, myList contains just ONE item and this item is "97" (I suppose that is the first two numbers of the first entry).

What is going on?

Thanks.

© Stack Overflow or respective owner

Related posts about applescript