• 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: Saving to array list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving to array list


  • Subject: Re: Saving to array list
  • From: Christopher Stone <email@hidden>
  • Date: Thu, 01 Nov 2012 18:32:27 -0500

On Nov 01, 2012, at 09:52, Brian Christmas <email@hidden> wrote:
I've got a requirement to save a whole years worth of hourly data.
______________________________________________________________________

Hey Brian,

I thought I'd look at this just a little differently.

I started with 365 separate files using your ' RunningTally' file's data for contents (assuming right or wrong that this was your starting point).

I changed the field delimiter to a semicolon, so it would not collide with the date-string (using BBEdit's Multi-File-Search).

The first script takes ~ 1 second to read and write all the files as textual data.  (The serial dates are just for demonstration.)

The second script is a simple example of reading using delimiter [delimiter] and until [delimiter].  It strips the last semicolon and the linefeed off the end of the record.

With open for access it's easy to read a file line-by-line until EOF to process the data.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------

set mailManagerFldr to ((path to desktop as text) & "Mail Manager Folder:")
set dailyTallyFldr to alias ((path to desktop as text) & "Mail Manager Folder:Daily_Tallies:")

tell application "Finder"
set tallyFiles to files of dailyTallyFldr as alias list
end tell

set _date to current date
set time of _date to 0

set collaterFile to mailManagerFldr & "2012_Collation.txt"

set fRef to open for access collaterFile with write permission

repeat with i in tallyFiles
set _temp to read i
write ((date string of _date) & ";" & _temp & linefeed) to fRef starting at (get eof of fRef) + 1
set _date to _date + (1 * days)
end repeat

write linefeed to fRef starting at (get eof of fRef)

close access fRef

-------------------------------------------------------------------------------------------

set _file to alias ((path to desktop as text) & "Mail Manager Folder:2012_Collation.txt")
set _record to items 1 thru -2 of (read _file using delimiter ";" until linefeed)

-------------------------------------------------------------------------------------------

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Checking on the existence of a file
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: Saving to array list
  • Next by thread: Re: Checking on the existence of a file
  • Index(es):
    • Date
    • Thread