3

I have joined a CSV file to a shapefile by a common key in QGIS. Not all records in the shapefile and CSV had corresponding keys.

This left some records in the shapefile as NULL.

i.e.

 City     School_ID   ID_no   Total
London    1234       1234     12
Glasgow   4321       4321     10
Bristol   4444       NULL     NULL

This is just a small slice of the data. The actual data has about 12000 records.

Is there any way to delete all records/rows with NULL values?

3
  • 1
    Can't you just sort the data, so all NULL values are on top or bottom of the attribute table, then manually highlight the rows and delete them? Even with 12000 records it should be easily done.
    – gHupf
    Commented Aug 17, 2018 at 13:36
  • Hi @gHupf, my sentiments exactly. However, there only seems to be an option to delete fields, as opposed to delete rows.
    – Will.S89
    Commented Aug 17, 2018 at 13:41
  • Hi @BERA, thank you for your reply. I know ArcGis allows you to keep only matching records, but in QGIS when joining vectors - there does not appear to be an option to select "join only matcihng records".
    – Will.S89
    Commented Aug 17, 2018 at 13:48

1 Answer 1

10

In the attribute table, choose Select by Expression and write "FIELD_NAME" IS null (replace FIELD_NAME with your actual field names, of course). Click "Select Features", then simply delete the resulting selected features.

8
  • Hi Nathan, Thank you for replying. There does not seem to be a delete button for records in the attributes view. The only delete button seems to correspond to fields or columns. THis is where I am having the issue.
    – Will.S89
    Commented Aug 17, 2018 at 13:46
  • 3
    Allow editing for the layer (maybe you have to save it as a shapefile first), then there's this nice red trash bin you can use to dispose of your unwanted features. You cannot delete single table fields, only rows or columns.
    – Erik
    Commented Aug 17, 2018 at 13:47
  • If you click on the number on the left of the attribute table, the whole row gets highlighted and you can just delete it.
    – gHupf
    Commented Aug 17, 2018 at 13:48
  • You can also choose Edit->Cut features (or use the scissors icon that's right next to the trash bin) if you want to keep the features in your clipboard.
    – Nathan
    Commented Aug 17, 2018 at 13:53
  • @Erik - thank you so much ! I did not have the editing setting on!
    – Will.S89
    Commented Aug 17, 2018 at 14:00

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.