First of all item.split(' ') produces something like this:
['foo', '', '', '', '', 'spam', '', 'foo', '', '666']
if you have multiple spaces in line. Use item.split()
Second, file object has iteration interface, so it's possible to iterate over file lines this way:
for line in open('city.dat'):
data = line.split()
if data[-2] == 'CITYNAME':
count += 1
numbers += float(data[-1])
Third, ensure that 'CITYNAME' exists in your file
To prevent unnecessary readings from file and splitings it's better to store prepared data in memory:
data = map(lambda x: x.split(), open('city.dat'))
and filter it if needed:
filtered_cities = filter(lambda x: x[-2] == 'CITYNAME', data)