I am using an Azure Function written in python to read a shapefile that comes from a Blob. The configuration is
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "inputShp",
"type": "blobTrigger",
"direction": "in",
"path": "uploads/shapefile/{name}.shp",
"connection": "StorageConnectionString"
}
]
}
and the __init__.py script
import logging
from json import dumps
import shapefile
import azure.functions as func
def main(inputShp: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {inputShp.name}\n"
f"Blob Size: {inputShp.length} bytes")
reader = shapefile.Reader(inputShp.read())
But this throws an error
Exception: ShapefileException: Shapefile Reader requires a shapefile or file-like object.
I have tried using reader = shapefile.Reader(io.BytesIO(inputShp.read())) instead, which gives the error
error: unpack requires a buffer of 4 bytes
from Read Shapefile on Azure Functions
No comments:
Post a Comment