import arcpy
import os
in_data = r"R:\natura 2000\8847.04 MaP\7517-341_Horber_Neckarhaenge\Daten_Offenland\2014-11-12_PE_Maßnahmenentwurf\Reperatur\Reperatur.gdb\data\massnahmen_anm56_141117"
field_list = []
numeric_fields = ["Double", "Integer", "SmallInteger"]
fields = arcpy.ListFields(in_data)
for field in fields:
# if (field.type in numeric_fields):
field_list.append(field.name)
# convert the list of fields to a semicolor delimited string
fields = ";".join(field_list)
rows = arcpy.UpdateCursor(in_data, '', '', fields)
count = len(field_list)
for row in rows:
for k in range(count):
if row.isNull(field_list
): row.setValue(field_list
, 0) rows.updateRow(row)
This doesn't work? Why?
Solved! Go to Solution.
Johannes... In the academic world...I don't worry about those things
Fields to replace Null throught "0" are string fields
not sure what the question is, but if it is a string field, and you want a zero representation then shouldn't nulls be replaced with "0" not 0
We work here with a GIS System which doen't allow Null values, so I try to repair the shape. Like this it is not loadable in that other GIS System.
Tried "0", nothing happens.
Might it be that the path is not reachable for python, with the point inside?
... natura 2000\8847.04 MaP\7517-341_ ...
This one, if you are interestesd in:
Thanks for the link...interesting company
using the os module in Python here are the results with a truncated path/filename and yours
>>> p = r"R:\natura 2000\8847.04 MaP\7517-341_Horber_Neckarhaenge\Daten_Offenland\2014-11\test.py"
>>> import os
>>> path, file_name = os.path.split(p)
>>> path
'R:\\natura 2000\\8847.04 MaP\\7517-341_Horber_Neckarhaenge\\Daten_Offenland\\2014-11'
>>> file_name
'test.py'
>>> p = r"R:\natura 2000\8847.04 MaP\7517-341_Horber_Neckarhaenge\Daten_Offenland\2014-11-12_PE_Maßnahmenentwurf\Reperatur\Reperatur.gdb\data\massnahmen_anm56_141117"
>>> p
'R:\\natura 2000\\8847.04 MaP\\7517-341_Horber_Neckarhaenge\\Daten_Offenland\\2014-11-12_PE_Ma\xc3\x9fnahmenentwurf\\Reperatur\\Reperatur.gdb\\data\\massnahmen_anm56_141117'
>>> path, file_name = os.path.split(p)
>>> path
'R:\\natura 2000\\8847.04 MaP\\7517-341_Horber_Neckarhaenge\\Daten_Offenland\\2014-11-12_PE_Ma\xc3\x9fnahmenentwurf\\Reperatur\\Reperatur.gdb\\data'
>>> file_name
'massnahmen_anm56_141117'
>>>
so you can be the judge
(you might try moving the file to c:\ temp for testing
Thanks for the script.
Sorry for bothering you. It was a problem with one null geometrie feature.
So I should keep in mind to check the geometrie first.
Disy is quite a good solution, if you can't afford to pay esri exorbitant license fees.
Johannes... In the academic world...I don't worry about those things
But maybe you want to use a gis in which you can't load corrupt shape files 🙂