Skip to main content

I'd like to create a string attribute with a specific length. I'm using an Esri AGOL writer to create and write to a feature service. In AGOL, I want the Field length of this string to be 12.

 

In a PythonCaller, I'm using:

objText = '00123'

    feature.setAttribute("TextField_test", 'ABC' + objText)     

 

In AGOL, this creates a field of string type with a length of 254.

 

In an AttributeCreator (before the PythonCaller), I created the 'TextField_test' attribute with a value of @string(12). This creates an attribute a value of '@string(12)' which is obviously not what I want (the python overwrites that value). In AGOL, this creates a field of string type with a length of 200.

 

I understand that I could the User Attributes in the AGOL Writer to Manual and change the attribute to Width to 12, but I also have an Excel Writer and would have to set the Cell Width to 12 as well. During development, I'm adding and removing many attributes, and I don't want to manually change my attributes in multiple writers every time I make a change.

 

Any ideas on how I can create a string attribute with a length of 12 before getting to my AGOL and Excel writers? I'd like to keep the User Attributes for the writers set to Automatic.

 

I also just noticed that for a different attribute, I'm creating an 8 bit integer in an AttributeCreator with @int8(0) and the AGOL and Excel writers show this attribute as a string with a width of 200. That's not what I want or expect.

@datablue​ Try using a dynamic writer with the schema feature. The schema feature can be used to generate the field types. Tutorial here


@datablue​ Try using a dynamic writer with the schema feature. The schema feature can be used to generate the field types. Tutorial here

Thank you for your response. I've looked over that tutorial and will try to get through it soon.

 

I'm mainly concerned about the data types for the Esri AGOL Writer. Because of this, I'm thinking that I may want to consider modifying many attributes under User Attributes - Manual. I can change String Width to 12, etc. I wish I could quickly automate that. I can make all my changes before going to production (and not worry about it during development).

 

I will try to look at the tutorial to see if your suggestion of using a dynamic writer with the schema feature would be a better approach.


@datablue​ Try using a dynamic writer with the schema feature. The schema feature can be used to generate the field types. Tutorial here

The tutorial seemed straightforward. On step 5, I wasn't sure how to "Run the workspace and inspect the results" because I'm not familiar with the MapInfo TAB (MITAB) format.

 

I tried to quickly add an Excel Writer but it didn't work as I expected. Does the Excel Writer support a dynamic schema or did make an error with configuration? I've attached two screenshots. Thanks.

 

FeatureType-parm 

FeatureType-UserAttr


Reply