Skip to main content
Solved

Is there a way to truncate field widths to fit field's contents


Forum|alt.badge.img
Hi all,

 

 

I have a set of MapINFO TAB files that are coming from SQL. Their field widths are defaulted to CHAR 254. I would like to truncate the field widths to fit the largest width of the field's contents.

 

 

For instance,

 

FIELD1 CHAR 254 having rows aaaaa bb ccccccc dddd eeeee fffff ggggg

 

become truncated to

 

FIELD1 CHAR 7 

 

7 being the largest width of all the rows of FIELD1

 

 

Any help would be appreciated.

 

 

Thiru

Best answer by gio

Hi,

 

 

You can use "string length @Value(Field1)" to claculate the length.

 

 

Then you can for instance use a stististicscaluclator grouped by Field1 to get the -max value.

 

Then create concatenatenation "Field1 CHAR @Value(_max)" (space delimited in this example)

 

Then you can use  a Filewriter to create a schema file with 1st row "attribute Format"

 

and subsequent rows the created strings.

 

So ti looks like:

 

bute Format

 

Field1 CHAR @Value(7)

 

 

After this u can use a schemamapper to map this schema.

 

 

If fields are "unknowns" or if there are many fields, you need/can to use a attribute eploder to acces the "uknown" filednames.

 

 
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • Best Answer
  • April 14, 2015
Hi,

 

 

You can use "string length @Value(Field1)" to claculate the length.

 

 

Then you can for instance use a stististicscaluclator grouped by Field1 to get the -max value.

 

Then create concatenatenation "Field1 CHAR @Value(_max)" (space delimited in this example)

 

Then you can use  a Filewriter to create a schema file with 1st row "attribute Format"

 

and subsequent rows the created strings.

 

So ti looks like:

 

bute Format

 

Field1 CHAR @Value(7)

 

 

After this u can use a schemamapper to map this schema.

 

 

If fields are "unknowns" or if there are many fields, you need/can to use a attribute eploder to acces the "uknown" filednames.

 

 

Forum|alt.badge.img
  • Author
  • April 15, 2015
Thanks so much Gio, I will try these. 

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings