Я пишу код с использованием python для генерации точечного шейп-файла в ArcMAP.У меня есть 1000 случайных возможностей (в FileA), и мне нужно попробовать все из них.FileA - это индекс позиции FileB.
Кроме того, для каждой сгенерированной последовательности я смотрю на эволюцию площади полигона Вороного от 3 до 50 точек в каждой последовательности, содержащейвсего 50 баллов.
Когда я запускаю код, у меня появляется сообщение, которое меня смущает:
tempXYFile.writerow('{0},{1}'.format(coordinates[entry.toInteger()][0],coordinates[entry.toInteger()][1]))
AttributeError: 'str' object has no attribute 'toInteger'
Я буду признателен за любую помощь!
Это мойкод:
import csv
# create 1000 XY sequences
print 'Start of the script'
sequences = csv.reader(open('FileA.csv','rb'),delimiter=',')
coordinates = []
# read coordinates of volcanos and store in memory
print 'Start reading in the coordinates into the memory'
coordinates_file = csv.reader(open('FileB.csv','rb'),delimiter=',')
for coordinate in coordinates[1:]:
coordinates.append(coordinate)
del coordinates_file
##i = 1
for sequence in sequences:
## print 'sequence # {0}'.format(i)
j = 1
tempXYFile = csv.writer(open('tempXY.csv','wb'),delimiter=',') #add the parameter to create a file if does not exist
for entry in sequence:
tempXYFile.writerow('{0},{1}'.format(coordinates[entry.toInteger()][0],coordinates[entry.toInteger()][1]))
print 'Entry # {0}: {1},{2}'.format(j, coordinates[entry.toInteger()][0],coordinates[entry.toInteger()][1])
j = j + 1
i = i + 1
del tempXYFile
print 'End of Script'