I'm trying to mimic the FeatureWriter available in FME 2016 in FME2015.1 since upgrading is not an option. I'm using a pythoncaller with FMEObjects to try and do this. As a basis I use the sample python scriptBaseLineWriter.py that came with the installation with FME.
I start out by creating a unique filename for my GDB, then I a getting the schema from the feature, set the schema on the writer and write to the GDB.
import fmeobjects
Â
from fmeobjects import FMEUniversalWriterÂ
from fmeobjects import FMEUniversalReaderÂ
import randomÂ
import os, sys# Get variables and create output name for temp fGDB
Â
folder = FME_MacroValuesa'FME_SHAREDRESOURCE_TEMP']Â
ext = '.gdb'Â
current_files = os.listdir(folder)# Get a list of current FGDB's
Â
fgdbs = f]Â
current_numbers = u]Â
for curfile in current_files:Â
if curfile.endswith(ext):Â
fgdbs.append(curfile)Â
# Extract the numbers from the GDB filenamesÂ
for fgdb in fgdbs:Â
s = int(filter(str.isdigit, fgdb))Â
current_numbers.append(s)Â
print "List of fGDBs: ",fgdbsÂ
print "List of fGDBs: ",current_numbers#Prefix for the FGDB names
Â
db = '\\\\\\conversion_temp'# create a list of 0 - 999 and remove the existing numbers
Â
numbers = range(0,1000)Â
for x in current_numbers:Â
numbers.remove(x)Â
nr = random.choice(numbers)Â
# Create the filenameÂ
db = str(folder + db + str(nr) + ext)Â
print db# Create a log file object.
Â
logger = fmeobjects.FMELogFile()Â
logger.setFileName("baseLineWriter.log", False)#Create a writer
Â
ObjWriter = FMEUniversalWriter('GEODATABASE_FILE',db)Â
ObjWriter.open(db)def processFeature(feature):
Â
# Create schema feature to describe features sent to writer.Â
schemaFeature = featureÂ
ft = feature.getAttribute('fme_feature_type')Â
print "FT: ",(ft)Â
schemaFeature.setFeatureType(ft)Â
# Log the schema feature.Â
logger.logMessageString("Schema feature:")Â
logger.logFeature(schemaFeature)Â
# Add the schema feature to the writer.Â
ObjWriter.addSchema(feature)Â
# Log the data feature.Â
logger.logFeature(feature)Â
ObjWriter.write(feature)Â
ObjWriter.close()Â
feature.setAttribute('_loc',db)My workspace consists of a SHAPE-reader, the python caller and an inspector, so not much that could confuce FME. When I run the workspace, it throws me the error:
A field type of '-999' was specified, which is not valid. Please check the documentation on the Geodatabase Reader/Writer for information on valid field types.
When I look at the writer docs, the tekst "field type" is not on the page, so that doesn't help too much. My data contains columns with the value -999, but when I uncheck those on the reader, it still produces the same error. Does anyone have any thoughts?