TransWikia.com

Import of CSV vs. Join by attributes Batch

Geographic Information Systems Asked by William Ruzek on December 11, 2020

-Using QGIS 3.2-

I am trying to join 110 different CSV’s with the corresponding shapefiles. I started to use the ‘Join Attributes by Field Value’ batch process to quickly do this. First, is there any way to have an autofill when using only 1 shapefile? Or to autofill the Yes/No question on ‘Discard records’, the only thing that allows an autofill is the export option.

But the issues is that when selecting the folder of various CSV, it imports the data as string not integer, which then creates issues later with 110 shapefiles, as you can’t use Graduated symbology. The only way I have found to solve this is to use the ‘Add Layer-Delimited Text Layer’ which then works fine and imports them all as integers, but this only allows 1 input and then doing each csv before running the batch process.

Any suggestions would be useful or quicker ways to do this. I have tried with Modeler but can’t find a way to import the CSV’s without the same issue. I have also tried to Merge all the CSV’s beforehand, though having some issues with Pandas [https://stackoverflow.com/questions/23343919/how-do-i-merge-two-csv-files-based-on-field-and-keep-same-number-of-attributes-o]

Ultimately I would like 1 shapefile with all the columns of the 110 CSV linked to it.

One Answer

To fix your data type issue create a csvt file with the column types, see: https://anitagraser.com/2011/03/07/how-to-specify-data-types-of-csv-columns-for-use-in-qgis/

There is a limit for the number of columns in the attribute table for shape (dBase) format, the maximum number of columns is 254. You had better to use the GeoPack format (which is the default in QGIS 3.x).

If you are on linux you can use paste shell command to put all the csv files into one (if the order of rows is the same in all files or you have to sort them). See: https://www.geeksforgeeks.org/paste-command-linux-examples/.

Answered by Zoltan on December 11, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP