I am not far from a new bee in Python and i would like to parse a file as is :
Paris, 458 boulevard Saint-Germain
Paris, 343 boulevard Saint-Germain
Marseille, 343 boulevard Camille Flammarion
Marseille, 29 rue Camille Desmoulins
Marseille, 1 chemin des Aubagnens
The file contains : City, Street number, Street Type and Street Name
This order is always the same and the City is followed by a comma.
I had done this for now:
#!/usr/bin/python3.4
import readline
import sys
try:
f = open(sys.argv[1])
except:
sys.exit()
lines = f.readlines()
print(lines)
And i get this output:
['Paris, 458 boulevard Saint-Germain\n', 'Paris, 343 boulevard Saint-Germain\n', 'Marseille, 343 boulevard Camille Flammarion\n', 'Marseille, 29 rue Camille Desmoulins\n', 'Marseille, 1 chemin des Aubagnens\n']
Seems to be the thing to do but now i have 2 questions:
How can I make some lists for each one of the type (City, number, streetType, streetName) ?
Is there a librairy in Python that parses adresses in a list ? One that you would recommend ?