Resizing the width of fields.

3130
5
04-10-2014 12:24 PM
GlennThomson
New Contributor
My boss has requested an automated process that will make symbology and attribute tables of similar feature classes homogeneous based on a template. One of the main things he is looking for is having the widths of the fields of his attribute tables adjusted. Not just a single width, but different widths. I have searched high and low for some sort of a script or tool that can be added into a model and have come up short. Any ideas or guidance would be greatly appreciated.
0 Kudos
5 Replies
WilliamCraft
MVP Regular Contributor
Just to be clear, you are looking for a way to define the field lengths of specifically-named fields within a template that can be applied to any number of feature classes, right?  So for example, you would need a template that you can apply to 2 point feature classes, 1 line feature class, and 6 polygon feature classes such that they all have the same field names and associated field lengths.  Do I have this right?  If so, you can create the "template" as an XML workspace file and then import it into a geodatabase.  Which version of ArcGIS are you using?  Are you looking to do this in an automated way using something like Model Builder, are you wanting to write this in Python, or are you alright with importing the template manually each time?  A bit more detail and requirements would help if you can provide it so that we can help you in the best way possible.
0 Kudos
GlennThomson
New Contributor
Just to be clear, you are looking for a way to define the field lengths of specifically-named fields within a template that can be applied to any number of feature classes, right?


Thank you for your response. What I am looking for is a way to decrease field width automatically so my boss is able to view the attribute table quickly and without scrolling. What I have are polygon shapefiles that are submitted by companies and need to be reviewed. So he wants a process that is going to convert these submissions into files/layers that will look the same for each submission for easier review. Everything seems doable with the exception of setting width values to the field columns. I am looking for any way to incorporate this into a python script or model.
0 Kudos
WilliamCraft
MVP Regular Contributor
Thank you for your response. What I am looking for is a way to decrease field width automatically so my boss is able to view the attribute table quickly and without scrolling. What I have are polygon shapefiles that are submitted by companies and need to be reviewed. So he wants a process that is going to convert these submissions into files/layers that will look the same for each submission for easier review. Everything seems doable with the exception of setting width values to the field columns. I am looking for any way to incorporate this into a python script or model.


Ok, so you're not looking to reduce the width of the actual fields themselves... just the real estate that the entire attribute table takes up on the screen.  Is your boss going to be looking at the attribute table in ArcMap when it's maximized to full screen?  Are all of the incoming Shapefiles going to have the exact same fields or are they all going to be different?  Depending on how many fields there are and the maximum character length is for each of the fields, you may not be able to fit the entire attribute table on the screen such that the fields all fit to their maximum value without requiring the user to scroll the table to the right to see the rest of the data.  Lastly, once you adjust the fields to what you want I am not sure that those field width settings persist when re-opening a map document.  Even swapping out the data source might not work.  I think we need some more info from you on the questions above before determining what solution might be possible.
0 Kudos
WilliamCraft
MVP Regular Contributor
What I am looking for is a way to decrease field width automatically so my boss is able to view the attribute table quickly and without scrolling.


As I think about this more based on the comment above, one thing that could work is to highlight ALL fields in your attribute table and then either (1) double click on one of the black line separators between fields to see if they automatically resize to fit the values or (2) drag one of the black line separators between fields manually to make all fields the same width (regardless of character value length).  It's a manual process, and you'll likely need to do it for each Shapefile you add to your map document, but that might be the only way to see all of your attributes at once.
0 Kudos
KimOllivier
Occasional Contributor III
It is really annoying to have text fields 255 chars wide containing 10 chars which result from loading in spreadsheets or CSV files etc.
I have written a scanner in awk that counts the maximum width of the contents of each field so you can round them up and resize the fields.

The obvious way is to use FME (or the Data Interoperability Extension) to reprocess the inputs to standardise the field widths. You can also reorder the fields easily.

You can set the field widths in a SCHEMA.INI (see Microsoft help) before you load text files.

If the sources are shapefiles then it is possible to copy the file using Conversion/FeatureclassToFeatureclass with a Field Mapping to redefine the output field widths. This is harder to program.

Note that in really wide fields you can change the height of the rows in the table and the contents will wrap! I only just discovered this after 10 years of using tables.

The trouble with formatting tables is that its all manual settings and does not persist when you close the table.
0 Kudos