• 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: parsing a large text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsing a large text file


  • Subject: Re: parsing a large text file
  • From: Gnarlodious <email@hidden>
  • Date: Thu, 6 Jul 2006 15:47:33 -0600

For such a truly gigantic text file your best bet would be shell. I
normally do something like:

-- copy the file to a temporary location
do shell script "cp -L ~/Music/iTunes/iTunes\\ Music\\ Library.xml
/private/tmp/tmp"
--  truncate playlists
do shell script "sed '/<key>Playlists<\\/key>/,$d'
/private/tmp/tmp>~/Desktop/iTunes.html"
-- remove any Mac returns in the "Comments" field
do shell script "tr -d '" & (ASCII character 13) & "'
<~/Desktop/iTunes.html>/private/tmp/tmp"
-- set up html table columns
do shell script "perl -ne 'print while
s/.*<key>(Name|Artist|Album|Genre|Size|Year|Comments)<\\/key><[^>]*>([^<]*)<\\/[^>]*>/<td
class=\\1>\\2/g' /private/tmp/tmp>~/Desktop/iTunes.html"

As you can see, with each process the file alternates overwriting the
previous completed file. This is an extremely fast and reliable way to
process large files, because each file is read, processed and written
one line at a time. It is also easy to develop since you can examine
each file incrementally. You can see the entire script here:
http://Gnarlodious.com/Apple/AppleScript/Scripts/iTunes-iPage.html

-- Gnarlie
_______________________________________________
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: parsing a large text file
      • From: Emmanuel <email@hidden>
References: 
 >parsing a large text file (From: email@hidden)

  • Prev by Date: Re: parsing a large text file
  • Next by Date: Re: UI scripting "Show Infos"
  • Previous by thread: Re: parsing a large text file
  • Next by thread: Re: parsing a large text file
  • Index(es):
    • Date
    • Thread