• 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
Reading files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading files


  • Subject: Reading files
  • From: Malcolm Fitzgerald <email@hidden>
  • Date: Wed, 19 Oct 2005 18:19:29 +1000

Reading every line of a long file takes a long time with applescript. I have a short list of line numbers that I want to read from a long file.

This is what I'm doing:

-- read the file -- this takes a minute or more on /usr/share/dict/web2

set fRef to open for access POSIX file f
try
    -- we have a list of line numbers to be read from a long file
	repeat with i from 1 to length of lineNumbers
		repeat (item i of cIndex) times -- skip this number of lines
			read fRef before cr
		end repeat
		read fRef before cr
		set end of wordList to result
	end repeat
	close access fRef
on error
	close access fRef
end try

How can I improve this?


Malcolm Fitzgerald ph: 02 93180877 Database Manager fax: 02 93180530 The Australian Society of Authors www.asauthors.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Reading files
      • From: Rob Stott <email@hidden>
    • Re: Reading files
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Excel Scripting
  • Next by Date: Re: Reading files
  • Previous by thread: RE: Slow script with long lists
  • Next by thread: Re: Reading files
  • Index(es):
    • Date
    • Thread