[LUAU] Using SED to extract song, artist, and album from my iTunes Music List Export
Julian Yap
julian_yap at yahoo.com
Tue Sep 26 11:32:45 PDT 2006
On Tue, 2006-09-26 at 07:59 -1000, Tim Newsham wrote:
> If you know perl or python or some other more general scripting language
> with good regular expression support, its probably easier and cleaner
> to implement what we did above and as others suggested, thats the
> way to go. But, if you don't know one of those languages, learning
> a little bit of sed or awk (or even cut) can get the job done and is
> a lot easier to pick up than a new (general) language...
Jim said in a later post that it's tab delimited.
In Python, create a file, say 'reader.py':
------
#!/usr/bin/python
import csv
import sys
filename = sys.argv[1]
csv_reader = csv.DictReader(open(filename, 'rb'), delimiter = '\t')
for row in csv_reader:
print '"%s" %s %s' % (row['Name'], row['Artist'], row['Album'])
------
Takes one argument from the command line.
So if given executable permissions:
./reader.py songs.txt
Otherwise:
python reader.py songs.txt
~ Julian
More information about the LUAU
mailing list