I have a function in python that parses in a file that looks like this:
Led Zeppelin
1979 In Through the Outdoor
-In the Evening
-South Bound Saurez
-Fool in the Rain
-Hot Dog
-Carouselambra
-All My Love
-I'm Gonna Crawl
Led Zeppelin
1969 II
-Whole Lotta Love
-What Is and What Should Never Be
-The Lemon Song
-Thank You
-Heartbreaker
-Living Loving Maid (She's Just a Woman)
-Ramble On
-Moby Dick
-Bring It on Home
Bob Dylan
1966 Blonde on Blonde
-Rainy Day Women #12 & 35
-Pledging My Time
-Visions of Johanna
-One of Us Must Know (Sooner or Later)
-I Want You
-Stuck Inside of Mobile with the Memphis Blues Again
-Leopard-Skin Pill-Box Hat
-Just Like a Woman
-Most Likely You Go Your Way (And I'll Go Mine)
-Temporary Like Achilles
-Absolutely Sweet Marie
-4th Time Around
-Obviously 5 Believers
-Sad Eyed Lady of the Lowlands
It is supposed to read in the file until it hits the new line and then stop reading it and print what it has read. But, for some reason it is stuck in an infinite loop of reading new lines and I cannot pinpoint why. Would there be a simple fix for this? Maybe something small I am overlooking? Any help would be greatly appreciated!
def parseData() :
filename="testdata.txt"
file=open(filename,"r+")
while file.read() not in ['\n', '\r\n']:
album=file.read()
print album