2

When I import a CSV file of census data, the length and precision of all of the fields are zero.

enter image description here

As a result, when I try to join the census data with a TIGER file of corresponding census block groups, the joined fields are "NULL."

enter image description here

How do I prepare the CSV file for an effective join?

Both the data of the CSV file and the field on which the join is based are in the TIGER file are string format.

3
  • Are the length and precision really 0? When creating an attribute 0 means maximum (254 for a shapefile for example)
    – LeoC
    Commented Apr 11, 2020 at 5:20
  • 2
    Welcome to GIS.SE! CSVs always have a length and precision of 0 when dragged and dropped into QGIS - the format doesn't allow for such a definition (and all data is imported as strings so precision is irrelevant). The reason why your join isn't working is likely to be some other issue. I just tried joining a CSV I dragged in with 0 length and precision for all the fields, but had no problem joining the data. My first suggestion would be to check if your CSV join field has any leading or trailing spaces, or other characters (like an apostrophe ' before the text if handled in Excel).
    – she_weeds
    Commented Apr 11, 2020 at 9:35
  • 2
    Also, if the CSV file was saved in Excel and the join field is a series of numbers with more than 15 digits, check that the numbers do actually match with your TIGER file - because Excel will convert the 16th digit onwards to zeroes unless specified as text
    – she_weeds
    Commented Apr 11, 2020 at 9:46

1 Answer 1

1

If you want to specify field types and precision you would need to create a companion csvt file. It's actually quite simple.

This primer should get you started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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