WEEK07: File I/O, top-down design
---------------------------------------------------------------
F: more File I/O
QUIZ 3
YOUR TURN:
- I have a file with itunes data in it: "/scratch/knerr/itunes.csv"
- csv stands for comma-separated-values:
$ head -4 /scratch/knerr/itunes.csv
Lights,Ellie Goulding,3:32:00,Pop,4/9/2012 15:15:00,1,Lights,2011
Won't Be the Last Time,Justin Townes Earle,3:12:00,Singer/Songwriter,4/8/2012 19:32:00,0,Nothing's Gonna Change the Way You Feel About Me Now,2012
Maria,Justin Townes Earle,2:37:00,Singer/Songwriter,4/8/2012 19:31:00,1,Nothing's Gonna Change the Way You Feel About Me Now,2012
Blues Clair,Django Reinhardt,3:05:00,Jazz,4/7/2012 9:25:00,0,The Best Of,1996
- each line in the file represents one song in my itunes library
- each line has 8 fields, separated by commas:
song name, artist, running-time, genre, date-of-purchase, number of plays, album, year
- write a python program to figure out the name of the most-played song
in that itunes file
- here's a harder problem, just to think about (we'll do sorting in a
few weeks): how would you read in all the itunes data and store it
in a variable, so you could later sort it?
$ python itunes-advanced.py
--------------------------------------------------
Do You Feel by The Rocket Summer -- 155 plays
Tamacun by Rodrigo y Gabriela -- 149 plays
It's On by Superchick -- 140 plays
How Far We've Come by Matchbox Twenty -- 129 plays
Big Yellow Taxi by Counting Crows & Vanessa Carlton -- 119 plays
Shining Star by Earth| Wind & Fire -- 117 plays
Let's Get Loud by Countdown Singers -- 113 plays
Rockstar by Hannah Montana -- 113 plays
Imperial March by John Williams; Boston Pops Orchestra -- 112 plays
Everyday Superhero by Smash Mouth -- 111 plays
--------------------------------------------------