I've been working on an add-in for Pro 3.0 that automates fetching various GIS data from online sources, processing them and adding them to our projects. Sometimes it would be very handy if the geoprocessing tools could accept a System.IO.Stream as input rather than a file.
Currently, I am downloading GeoJSON files archived in .zip files and have to extract the files to disk before passing the extracted files to geoprocessing tools. (In this case, JSON to Features) If I could pass a Stream, I wouldn't have to write all the files to disk first, I could access the ZipArchiveEntry's Stream directly without extracting, processing, and deleting the files again.
I can imagine other use cases as well, like passing a Stream directly from HttpClient to a geoprocessing tool.
@DanielRatzlaff Would this code be helpful to you?
import json
import zipfile
d = None
data = None
with zipfile.ZipFile("./data/drug-event-Q4-0001-of-0013.json.zip", "r") as z:
for filename in z.namelist():
print(filename)
with z.open(filename) as f:
data = f.read()
d = json.loads(data.decode("utf-8"))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.