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_MacroValues['FME_SHAREDRESOURCE_TEMP']
ext = '.gdb'
current_files = os.listdir(folder)
# Get a list of current FGDB's
fgdbs = []
current_numbers = []
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?