# QGIS: Change String to Number values in the shapefile

In QGIS, you can convert a string to a number using the "Field Calculator" tool. First, open the attribute table for the layer you wish to modify. Next, click the "Open Field Calculator" button. In the "Expression" box, type "to\_real(" followed by the name of the field containing the string you want to convert, and closing parenthesis. For example, to convert a string field named "string\_field" to a numeric field, input "to\_real("string\_field")" in the Expression box. You can also modify the output field name and data type by selecting the appropriate options. Finally, click "OK" to complete the conversion. The original string field will remain in the attribute table, while the new numeric field will be added to the table.

<figure><img src="https://3272281156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYICBELdyAXXebKAzfLOR%2Fuploads%2Fi3rxrGu9XbcEMSGWGGEX%2FScreenshot%202023-04-03%20at%2017.22.03.png?alt=media&#x26;token=1425fbc0-f7fa-4d0d-b794-b50c8db37b8d" alt=""><figcaption></figcaption></figure>

1. Open "Properties"
2. Go to "Field Calculator"
3. Check "Update Existing field"
4. to\_real("attributeName")
5. Save edits
6. Repeat the same for each attribute

   <figure><img src="https://3272281156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYICBELdyAXXebKAzfLOR%2Fuploads%2Fc6LPt5wG8QlPkfn1B00s%2FScreenshot%202023-04-03%20at%2017.29.49.png?alt=media&#x26;token=86437f74-6d54-4cae-8e04-ff319e4769a6" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.geopard.tech/geopard-tutorials/gis-quick-hints/qgis-change-string-to-number-values-in-the-shapefile.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
