try: package = "zarr" package_version = version(package) major_version = int(package_version.split(".")[0]) # Extract the major version if major_version == 3: print(f"The package major version is {major_version}.") import zarr import fsspec # strip leading 's3://' from url url1 = url1[5:] url2 = url2[5:] fs = fsspec.filesystem("s3", asynchronous=True) store1 = zarr.storage.FsspecStore(fs, path=url1) store2 = zarr.storage.FsspecStore(fs, path=url2) file1 = zarr.open(store=store1) file2 = zarr.open(store=store2) else: print(f"The package major version is {major_version}.") import s3fs fs = s3fs.S3FileSystem(anon=True) file1 = s3fs.S3Map(url1, s3=fs) file2 = s3fs.S3Map(url2, s3=fs) except PackageNotFoundError: print(f"{package} is not installed")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter