• 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 input from a delimited source file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading input from a delimited source file


  • Subject: Reading input from a delimited source file
  • From: Joseph Weaks <email@hidden>
  • Date: Wed, 8 Jan 2003 13:10:58 -0600

What am I doing wrong? I have a text file that has paragraph delimited data. Basically, I want to read the content of the first paragraph, do stuff with it, then repeat with each paragraph. Here's what I've been trying:

-- Begin code snippet
Property sourceFile : "Source.txt"

set theSource to (open for access file ((path to desktop as string) & sourceFile as string)

set AppleScript's text item delimiters to (ASCII character 13)
set sourceList to text items of theSource

repeat with x from 1 thru (length of sourceList)
set eachSource to item x of sourceList as string
-- do stuff with eachSource.
end repeat

close access theSource
-- End code

I'm getting a "Can't get every text item of ..." error.
Is there a better way to go about this? Some kind of
set eachSource to paragraph x of theSource?

Right now, each paragraph is only one word, so there's not a problem loading the whole file into memory. I would like to also see a nice clean handler that works if the source file is too long to load all at once.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Reading input from a delimited source file
      • From: Bill White <email@hidden>
    • Re: Reading input from a delimited source file
      • From: Jay <email@hidden>
References: 
 >Re: Parsing HTML (From: has <email@hidden>)

  • Prev by Date: OSX script to change/copy file icon ?
  • Next by Date: New Version of SuperPrivacy to support Safari released
  • Previous by thread: Re: Parsing HTML
  • Next by thread: Re: Reading input from a delimited source file
  • Index(es):
    • Date
    • Thread