• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading txt file line by line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading txt file line by line


  • Subject: Re: Reading txt file line by line
  • From: JJ <email@hidden>
  • Date: Wed, 17 Oct 2001 04:41:01 +0200

> Hello all.
> I have a rather large text file that I'd like to read into line by line.
> So far I have the following:
>
> on open fileList
> repeat with oneFile in fileList
> set oneFile to oneFile as string
> tell application "Finder"
> set fileName to name of file oneFile as text
> if not (fileName ends with ".txt") then
> display dialog "Cannot process file " & fileName & " because
> it is not a text file!" buttons "OK" default button 1 with icon 2
> else
> set OPENFILE to open for access file oneFile
> set oneLine to read OPENFILE until return as {text} using
> delimiter {tab, return}
>
> end if
> end tell
> end repeat
> end open
>
> The part that I want to use is the:
> set oneLine to read OPENFILE until return as {text} using
> delimiter {tab, return}
> But I want to repeat thru every line without having to read the entire file
> into my variable. What I am asking is after getting the first line returned
> to me, how do I then do the same line of code for the 2nd, 3rd, 4th, etc....

repeat
try
set file_contents to read OPENFILE for 100 from x
on error
set last_file_contents to (read OPENFILE from (theLength - x) to
theLength)
exit repeat
end try
set x to x + 100
end repeat


  • Prev by Date: Re: Dissatisfied with Display Dialog command
  • Next by Date: Re: applescript-users digest, Vol 2 #1203 - 13 msgs
  • Previous by thread: Reading txt file line by line
  • Next by thread: Quark 4.11 + OS X 10.1 = ?
  • Index(es):
    • Date
    • Thread