Ich möchte eine CSV-Spalte durchsuchen und mein Skript die Gesamtzahl der Male jedes Handy zurückgegeben wird zurück ... Hier ist mein Code, aber ich bin mir nicht sicher was das Problem ist ...Zählen Sie die Häufigkeit, in der etwas in einer CSV-Spalte auftritt
import arcpy
fc = "C:\Script\SAMPLES\SAMPLES.csv"
field = "phone"
iPhone = 0
Android = 0
other = 0
cursor = arcpy.SearchCursor(fc)
for row in cursor:
#print(row.getValue(field))
if row.getValue(field)=='iPhone':
iPhone = iPhone + str(iPhone)
print "The number of iPhones: " + iPhone
elif:
Android=Android + str(Android)
print "The number of Androids: " + Android
elif:
other=other + str(other)
print "The number of other: " + other
Ich habe auch den Fehler aufgenommen, den ich erhalte.
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\Lib\site- packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\Script\searchcursor.py", line 11, in <module>
iPhone = iPhone + str(iPhone)
TypeError: unsupported operand type(s) for +: 'int' and 'str'