Bonjour,

J'ai lancer ce script et j'ai une erreur de ce type :

Traceback
File « geo.py », line 10, in
for ligne in inputData:
_csv.Error: iterator should return strings, not byte

Mon Script geo.py :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import csv
from geopy.geocoders import Nominatim
geocoder = Nominatim()
inputFile = open('adresses.csv', 'r')
outputFile = open('resultat.csv', 'w')
try:
    outputData = csv.writer(outputFile, delimiter=';', lineterminator='\n')
    outputData.writerow(('adresse', 'latitude', 'longitude'))
    inputData = csv.reader(inputFile, delimiter=';')
    for ligne in inputData:
        adresse = ligne[0]
        try:
            location = geocoder.geocode(adresse, True, 30)
            outputData.writerow((adresse, location.latitude, location.longitude))
        except Exception as inst:
            print(inst)
finally:
    inputFile.close()
    outputFile.close()
exemple de mon csv :

12 AV LOUIS ARAGON 31700 BLAGNAC
13 AV LOUIS ARAGON 31700 BLAGNAC
15 AV LOUIS ARAGON 31700 BLAGNAC
10 AV LUCIEN SERVANTY 31700 BLAGNAC
11 AV LUCIEN SERVANTY 31700 BLAGNAC
12 AV LUCIEN SERVANTY 31700 BLAGNAC
13 AV LUCIEN SERVANTY 31700 BLAGNAC

merci pour votre aide