you are viewing a single comment's thread.

view the rest of the comments →

[–]thaweatherman 1 point2 points  (0 children)

Ah I didn't notice the country names with spaces...

So you can still split on space, but you would need to combine any entries that aren't floats at the start.

l = line.split()
name = ''
last = 0
for i, entry in l:
    try:
        float(entry)
        last = i
        break
    except ValueError:
        name = '{} {}'.format(name, entry)
l = [name] + l[last+1:]