Description:
- Work with data via http
Resources:
- [Source Code] https://filesystem-spec.readthedocs.io/en/stable/_modules/fsspec/implementations/http.html
Example 1
Section titled “Example 1”Fetch data synchronously (slow!)
from fsspec import filesystem
fs = filesystem("http")
url1, url2, url3 = "http://google.com", "http://bing.com", "http://eugo.io"out = fs.cat([url1, url2, url3]) # fetches data concurrentlyExample 2
Section titled “Example 2”Fetch data asynchronously (faster!)
from fsspec import filesystemimport asyncio
fs = filesystem("http")
url1, url2, url3 = "http://google.com", "http://bing.com", "https://eugo.io"
async def work_coroutine(): fs = filesystem("http", asynchronous=True) session = await fs.set_session() # creates client out = await fs._cat([url1, url2, url3]) # fetches data concurrently await session.close() # explicit destructor
asyncio.run(work_coroutine())Example 3
Section titled “Example 3”Download remote data asynchronously
from fsspec import filesystemfrom pathlib import Pathimport asyncio
tmp = "/tmp/ganymede_demo"Path(tmp).mkdir(parents=True, exist_ok=True)
url = "https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"
async def download_csv(): fs = filesystem("http", asynchronous=True) session = await fs.set_session() out = await fs._get(url, f"{tmp}/titanic.csv") await session.close()
asyncio.run(download_csv())ganymede is made by Eugo