[GIS] Table join with .csv file results in null fields after join

attribute-joinscsvqgistable

Similar to questions already asked about .dbf files, I'm attempting to join .csv files to a .gdb or shapefile coverage in QGIS. The tables as added to QGIS prior to the join look fine, but after the join is complete, the amalgamated table has NULL values for all joined fields. The same happens with a variety of different tables, and regardless of whether I'm joining to a shapefile or .gdb file.

I'm running QGIS 2.0.1 on a OSX 10.8.5. The original table files are contained in .mdb format so I've purchased and used the MDB ACCDB Viewer to export them to .CSV The fact that they are fine when viewed separately leads me to believe the issue is with the join procedure, not the tables themselves.

Suggestions?

Best Answer

It's best if you make sure the two fields have the same data type.

The field type can't be changed for shapefiles. But it's easy to create a new empty text field and make that equal to the integer field.

You can use a field calculator expression that looks something like: tostring( "INT_FIELD" ) and simply replace INT_FIELD with the name of the actual integer field.

You can easily change a CSV layer attribute value from text <-> number too.


UPDATE

If you are getting null values, you could try keeping the join, but just close and re-open that attribute table to see if the joined values are there (or even close/re-open QGIS).

I've been able to successfully join a csv to a shapefile with a mixture of field types so string vs integer shouldn't be the issue.


UPDATE 2

Looks like in order to get rid of the null values, they have to actually have a matching record in the corresponding table that joins are being made from. But in the image below, you can see that some do have a matching record:

successful joins in yellow