Using QGIS 2.16.2 I would like to export the unique values in a shapefile string attribute field to a new database table (which would contain a single field listing the unique values). The Vector > Analysis Tools > List Unique Values tool correctly selects the unique values, but the only output option is an .html file. Is there some way to output to a .dbf, or .csv format?
The shapefile is a line format, so the Dissolve tool does not work (it requires a polygon input), as described in Getting list of distinct values from shapefile field using QGIS?
Best Answer
Go to
DB Manager -> Virtual Layers -> QGIS layers
, click onSQL Window
button (or press F2), and write the next SQL expression:Once you get the result table, click on
Load as new layer
, uncheckGeometry column
, and click onLoad now!
.Now you have a table layer in QGIS, which you can export with
right click -> Save As...
to a CSV file, for example.