I am trying to export several layers as CSV-files since I need to analyze them in another software. However, I cannot get my code to work. I am new to Python. Currently working in QGis 3.10.9. I would like all the fields in the attribute table to get exported. Here is the code I am using:
file_path = "/Users/user/Desktop/gis/Vikter/NUTS_ID_AT111978Q1.gpkg"
layer = QgsVectorLayer(file_path, "NUTS_ID_AT111978Q1", "ogr")
QgsVectorFileWriter.writeAsVectorFormat(layer, "/Users/user/Desktop/gis/Excel/NUTS_ID_AT111978Q1.csv", "utf-8", None, "CSV", layerOptions = ['GEOMETRY=AS_XYZ'])
The error message I receive:
Traceback (most recent call last):
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 3, in <module>
TypeError: QgsVectorFileWriter.writeAsVectorFormat(): arguments did not match any overloaded call:
overload 1: argument 4 has unexpected type 'NoneType'
overload 2: argument 4 has unexpected type 'NoneType'
overload 3: argument 3 has unexpected type 'str'