Select to view content in your preferred language

Import Table — Set text field length to input field's max text value length

273
1
10-28-2024 11:05 AM
Status: Open
Labels (1)
Bud
by
Esteemed Contributor

ArcGIS Pro 2.9.5; Oracle 18c 10.7.1 EGDB

When importing a .CSV into an enterprise geodatabase as a standalone table using the Table to Geodatabase geoprocessing tool:

The text field lengths get set to 1073741822 characters by default, which is way too long. The max text value length in any of my text fields is 114 characters.

Bud_0-1730138569348.png

Instead of defaulting to a huge text field length, use the max length of the actual values in the field. 

Related: Get maximum text value length of multiple text fields

1 Comment
MicZatorsky_AEC

Use the input CSV and Pandas to find the maximum length value in each field.  Something like this:

 

import pandas as pd

# Read the CSV file into a DataFrame
df = pd.read_csv(r'c:\temp\foo.csv')  # Replace this with your actual file path

# Calculate the maximum length of the data in each field
max_lengths = df.astype(str).applymap(len).max()

# Display the maximum lengths for each field
print(max_lengths)

 

Then use that to create the target FC before population, or try Alter Field after.