0

I'm trying to come up with a Python script to convert CAD files to shapefiles. The Open() calls don't error they just return None. I've tried with and without the 'CAD' driver specified.

GDAL version 3030200, Python IDLE 3.7.9

in_format = 'CAD'
in_file = 'CAD:COH.DWG'

#in_ds = ogr.Open(in_file)
in_ds = ogr.GetDriverByName(in_format).Open(in_file)

if in_ds == None:
    print ("failed to open file [%s] using [%s] format" % (in_file, in_format))
    sys.exit("failed")

Any ideas or how can I find out what out why this is failing?

0

I have found that Open sometimes just returns a NoneType if it can't find the file. Maybe try passing in an absolute path (i.e. "C:\Users\...COH.dwg").

1
  • Thanks for the suggestion. I tried the absolute path with and without the CAD: prefix.
    – Bill
    Sep 14 at 20:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.