This is seemingly pretty simple. I have a csv file I want to add to the map. It is comma delimited and there is no lat/lon information. I will join it to a shapefile later. I used other examples from stackoverflow and this documentation in the QGIS cookbook to do it. I can add it with the following code:
uri = 'file:///Users/ep9k/Desktop/SandraMonson/CountByZip.csv?delimiter=,' csv_file = QgsVectorLayer(uri, 'Patient Data', 'delimitedtext') QgsProject.instance().addMapLayer(csv_file)
ZipCode, PatientCount, StateOrProvince should be the column headers, with data below. How can I read the first line as column headers and the rest as data in those columns?
Another thought I have, after looking at the QGIS cookbook documentation, I went into PyQGIS API documentation and into Module>Core Library> and looked for QgsVectorLayer and QgsProject, and it seems counterintuitive as a csv file is not a vector layer.