Skip to content

how to download files into local from remote #5200

Answered by Xuanwo
lizzzcai asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, please try read like a file:

import opendal
import polars as pl

# Init an operator.
op = opendal.Operator("fs", root="/tmp")

# Create a DataFrame.
df = pl.DataFrame({"name": ["Alice", "Bob"], "age": [20, 30]})
print(f"df: {df}")

# Open and write the DataFrame to the file.
with op.open("test.csv", mode="wb") as file:
    df.write_csv(file)

# Open and read the DataFrame from the file.
with op.open("test.csv", mode="rb") as file:
    read_df = pl.read_csv(file)
    print(f"read_df: {read_df}")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Xuanwo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants