Removing /n from text files

Hi there.
I have created a simple text file with notepad with the contents of:
1
2
3

When running
log fileContents
the output is: 1\n2\n3\n
I have attempted to use:
delete every occurrence of "\n" in fileContents
However this does not remove the "\n" from the content of the fileContents.
How can I remove these characters?
Thanks for your help in advance.

Comments

  • EggplantMattEggplantMatt admin ForumAdmin admin
    Those \n's are newline characters and you can remove them like this:
    delete return in filecontents
    
    However, if your intent is to iterate over the file line by line, then you can do something like the following and the newline characters will be ignored as a standard line ending character:
    repeat with each line of file "/path/to/myfile"
         // do something with the line of data
    end repeat
    
  • EggplantMattEggplantMatt admin ForumAdmin admin
    Original reply corrected.
Sign In or Register to comment.