2

I have joined a simple CSV file to my project and am attempting to change a string value to a real value. In editing mode, I bring up the field calculator and create a new field from the first field. I try to change the string to real by doing the command "toreal(nameofmyfield)". When I create the new field though, I get NULL for every value, even though I see the normal numbers in the column I am trying to change.

Any idea what's going on?

2

You can not modify fields of a CSV file, because the CSV importer has limited writing ability.

Save the layer as a shapefile, and add it to the canvas. Then you can edit the fields with the field calculator.

  • Thanks a lot for the quick response. That makes a whole lot of sense. What do you mean by save the layer as a shapefile? I ended up manually entering a column in the attribute table so I could get what I wanted (for the column to be real numbers and not a string). – Eric Feb 11 '14 at 20:05
  • If the CSV file contains coordinates, you can save it as shapefile by rghtlick on the layer name -> Save As ... For non-geographic CSV data, you can try using a csvt file as described here: gdal.org/ogr/drv_csv.html – AndreJ Feb 11 '14 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.