0

I am very new in python and trying to read MapInfo (.TAB) file and convert it in to CSV format in following way:

import geopandas as gpd

input_file = 'F:/.../QGIS/sites.tab'

test = gpd.read_file(input_file, driver="MapInfo File")


output_file = 'F:/.../QGIS/new_sites_copy'

test.to_file(output_file, driver = "CSV")

The code creates the CSV file which contains only the header similar to MapInfo Tab file but no other attributes are available in csv file in respect to column heading. Below is the snip of output csv file:

enter image description here

And below is the error that showing after executing the code:

enter image description here

I have installed these modules for this purpose: numpy, pandas, shapely, gdal, fiona, pyproj, rtree, geopandas

Below are the supported drivers by geopandas (gpd.io.file.fiona.drvsupport.supported_drivers):

{'AeronavFAA': 'r', 'ARCGEN': 'r', 'BNA': 'rw', 'DXF': 'rw', 'CSV': 'raw', 'OpenFileGDB': 'r', 'ESRIJSON': 'r', 'ESRI Shapefile': 'raw', 'FlatGeobuf': 'rw', 'GeoJSON': 'raw', 'GeoJSONSeq': 'rw', 'GPKG': 'raw', 'GML': 'rw', 'OGR_GMT': 'rw', 'GPX': 'rw', 'GPSTrackMaker': 'rw', 'Idrisi': 'r', 'MapInfo File': 'raw', 'DGN': 'raw', 'PCIDSK': 'rw', 'OGR_PDS': 'r', 'S57': 'r', 'SEGY': 'r', 'SUA': 'r', 'TopoJSON': 'r'}

How do I solve this?

3
  • How is this a pyqgis issue? this is related to geopandas. have you checked that the layer is valid? have you tried simply using ogr2ogr or load the layer in QGIS and save as CSV? – Dror Bogin Feb 15 at 10:41
  • The layer is valid, I was able to convert it into shapefile but not in csv. Same issue I faced when I was trying to convert shapefile (different files not the converted one from tab) to csv format, same error. Load in qgis and save as csv is possible but that's not the intention to do. – user177357 Feb 17 at 10:39
  • Have you tried the answer here? – Dror Bogin Feb 17 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.