I am having issues with uploading (and reading) a DXF file using the dash upload component.
My end goal is to get all the information from the drawing layers and pass it into a json file using:
the python package “ezdxf” and;
the package methods in “ezdxf” —> readlines() or read()
My starting code is to test if this works is to get the total number of layers in a DXF file and save it into a dash store component. However I am having trouble getting “ezdxf” to successfully read the contents from the upload component.
Similar issues here. I have done some trial and error with base64 package as well as the io python core package with no success. A little bit like the example given by plotly below for excel.
def save_file(name, content):
"""Decode and store a file uploaded with Plotly Dash."""
data = content.encode("utf8").split(b";base64,")[1]
with open(os.path.join(UPLOAD_DIRECTORY, name), "wb") as fp:
fp.write(base64.decodebytes(data))