[GIS] Changing precision on a column in the attribute table without losing data

attribute-tablecsvqgisqgis-2

I have data in an Excel file that I want to join with a shapefile in my project.
The Excel file contains values like volumes. The Excel file and the shapefile I want to join it with both contain the same property names.

The problem is, when I join the two, I get too many decimals in the attribute table. I get six, but I only want it to be one.

I tested to change the format of the cells to one decimal, and then I saved the file as *csv. But, somehow I seem to loose data in the process? It should be 42 rows that contains data in the column i am working with, but I end up with only like 10?

Another thing is that my property names contains the letters Å. Ä and Ö, perhaps this complicates things?

I read the question How can I change the precision in the attribute table?, but it doesn't mention the problem with the data loss.

My question was tagged with , but I didn't write what version I'm using. I use QGIS 2.2.0. Would it help to upgrade to the latest version?

Best Answer

Notice that in this cases you can create a new column with the desired size and precision, and populate it's values with the "old" column values. After saving, your new column will have the wanted precision.

Take this exemple. I have a table with a column ("test") with a precision size 20 and precision 15.

enter image description here

I will open the field calculator (the abacus symbol), to create a new column with the right precision, and give it same values as the older column.

enter image description here

Checking my attribute table, I now have both columns with different precisions:

enter image description here

From this point you could simply delete the older column. But you probably want your new column to have the original name (and maybe column position)? For that, you can use the table manager plugin. If not installed you can get it in Plugins > Manage and Install Plugins. And it will be available at Vector > Table manager.

enter image description here

You should, select and delete the old column, and then select and rename the new column. (And move it up to the old column relative position?)

Notice you can take care of your Å, Ä and Ö characters with table manager as well.