I have a file of cencus data that I need to read and then manipulate in several ways. The file looks like this.
Population Housing Location
34340 15175 W
19661 8639 E
8026 3456 N
40633 14939 N
at this point I am only trying to read the data in. Once that is complete I was thinking about using a dic with the county name as the key, and then playing with different ways to format the output. i.e. printing all the (N)orth counties , or totaling the population.
below some code I wrote to read and format the data like this
CountyName Population Housing Location
#ifstream to get data for censuss. infile=open("G:/CSC/Programs/MSCEN/Misscen.dat") lineodd=infile.readline() while 1: lineeven=infile.readline() line=lineodd+" "+lineeven lineodd=infile.readline() print line infile.close()
I have suceeded at createing what looks like an infinte loop. So the question is, how do I make the loop stop after I get all the data in and is my plan of attack for the rest of the program going to work or am I way off course.
This was a program I had to write for a C++ course I took and I am using it to teach myself python. Thanx in advance!!