How to copy a column of numbers into a new column of text data type

5723
23
07-01-2015 08:41 AM
DanHoralík
New Contributor II

Hi, I'm a total amateur in ArcGIS. Can you please help me?

I have a table with a column in the "Double" data type. There are 6-digit numbers. Then I have another column (in the same table), which is empty and its data type is "Text, Length 6".

I need to copy the numbers from the first column into the second column. How do I do that?

I'm sorry, I even don't know if this is the right place to give this question.

0 Kudos
23 Replies
IanMurray
Frequent Contributor

Okay, so you just typed in the field name using Josh's method and it failed since it was expecting brackets on the field names.

Are you sure that 500620 was actually 500620 and not 500620.4?  The double field maybe only be showing a certain number of significant digits or numbers after the decimal, but in reality could have a large number of decimal places.  On the field properties, you can see how many significant digits or decimal places it is showing by clicking the numeric option, and can control the number of significant digits or decimal places it shows.

With 0 decimal places showing(Double Field)

Double with 0 Decimal Places.png

Changing Numeric Field Properties

Numeric.png

Change decimal places showing

ChangedDigits.png

New field values showing

MoreDigitsShowing.png

So your double field, might have some significant rounding issues, depending on the number of significant digits or decimal places it is showing.   The true value is stored in the table, but is just rounded for display purposes.

JayantaPoddar
MVP Esteemed Contributor

Hi Dan,

Go to Field Properties of <NumericColumn>. Reduce the number of significant digits to 5.

Now using FieldCalculator for <TextColumn>, just enter the fieldname of <NumericColumn> in the expression.



Think Location
0 Kudos
DanHoralík
New Contributor II

Hi Jayanta, I still have some problems. I have changed the number of significant digits to 5, for the numeric column. The format is Double, Precision 15, Scale 6. In the numeric column, my data are 6-digit numbers.

Now I'm trying to use the Field Calculator for the text column. The length is 6.

Should I select the parser VB script or Python? And in the field should I just write the name of the text column, which is kod? Or like this [kod]?

0 Kudos
IanMurray
Frequent Contributor

HI Dan,

When using the VB Parser, field names need to be in brackets, with the python parser, they need to be in exclamation points.  Instead of typing the field name out, it is easiest to select from the field from the fields list, it will add it to the calculation with the proper formatting for the parser selected.

DanHoralík
New Contributor II

OK, now I tried (in the Python parser) str(!kod!). kod is the name of the numeric column. I got results, but instead of 500010 I got 500011.0. Instead 500050 I got 500046.0. That's weird, right?

0 Kudos
IanMurray
Frequent Contributor

Also generally, if people are storing integer numbers instead of float/double, they would use a Long Int field type not a double, since they take up less space memory-wise.  Making a double field with no decimals is not usually likely.

DanHoralík
New Contributor II

That's weird. I probably shouldn't have played with that number of significant digits. The calculation changed the data in the number column, would you believe that? 500011 is the correct number, but 500010 is not. 500046 is the correct version, but 500050 is not.

But now I must input the original data in my table, because the numberic column got currupted. Too bad I've saved the edits, now I must reinput the original data.

0 Kudos
IanMurray
Frequent Contributor

Changing the significant digits showing should not change the values in your field, just change how they are displayed in the field.  The true values should still be in the table.  Try changing to allowing several decimal places, and see what numbers it shows.

Joshua Bixby​, please correct me if I've said anything erroneous, I defer to your knowledge and experience on stuff like this.  Just working off what I know.

0 Kudos
DanHoralík
New Contributor II

OK, I re-added the original data.

The numeric column kod is in the Double format, Precision 15, Scale 6, Number of decimal places 6, Number of significant digits 6. Tha example of the data is 500011, 500020, 500046, 500259, 500291 etc.

Now I'll make a calculation for the text column in the Text format, Length 6.

It's given me the exact same numbers, but there is also .0 at the end of each. For example 500011.0, 500020.0, 500046.0.

This is good, I'm getting closer Now I just need to figure out, how to cut the .0 at the end. Should I change the number of significant digits from 6 to 5? Or something else?

0 Kudos
IanMurray
Frequent Contributor

You can either set the number of significant digits OR number of decimal places, not both.  If you have it set to 6 significant digits, it will by defintion be rounding the values. Try changing the significant digits to 15(the precision of the field) and see what the values in kod look like.