I have a bunch of text files with tabular data. It looks like this:
1. BRISTOL CITY 42 16 4 1 43 13 8 7 6 23 27 59
2. Plymouth Argyle 42 18 3 0 47 6 5 4 12 14 23 53
3. Swansea City 42 13 6 2 46 14 9 3 9 32 31 53
4. Brighton & Hove Albion 42 15 3 3 39 13 5 8 8 13 21 51
5. Luton Town 42 14 4 3 47 18 7 3 11 21 31 49
6. Millwall 42 9 10 2 27 13 5 8 8 18 27 46
7. Portsmouth 42 10 5 6 34 20 9 3 9 24 32 46
8. Northampton 42 13 6 2 40 17 4 5 12 14 27 45
9. Swindon Town 42 14 4 3 41 17 3 7 11 21 39 45
10. Watford 42 10 6 5 35 23 7 4 10 22 31 44
11. Queen's Park Rangers 42 10 4 7 34 24 6 6 9 20 25 42
12. Charlton Athletic 42 11 6 4 33 14 3 8 10 22 37 42
13. Bristol Rovers 42 7 9 5 25 19 6 7 8 10 17 42
14. Brentford 42 9 4 8 27 23 4 8 9 14 28 38
15. Southend United 42 10 6 5 35 18 2 7 12 14 36 37
16. Gillingham 42 13 4 4 38 18 2 3 16 13 41 37
17. Merthyr Town 42 10 4 7 27 17 1 10 10 12 31 36
18. Norwich City 42 8 7 6 29 26 5 3 13 22 45 36
19. Reading 42 9 8 4 24 15 1 6 14 12 40 34
20. Exeter City 42 10 4 7 27 18 3 3 15 20 66 33
It's very regular, but there's no standard separator and the column widths are not standard from table to table (even within the same files). (Spaces alone aren't a sufficient delimiter, as many of the names contain spaces and in some places, columns are separated by only a single space.)
I want to parse this into Python objects, but it's not really clear what the best way to do that is. Is there a way to use the CSV module to parse it? Do I need to use regex? Has someone written an awesome python library for parsing tabular text files?
csvmodule? Is it not working?