civis.io.file_to_dataframe

civis.io.file_to_dataframe(file_id: int, return_as: str = 'pandas', compression: str = 'infer', client: APIClient | None = None, **read_kwargs) pd.DataFrame | pl.DataFrame[source]

Load a dataframe from a CSV stored in a Civis File.

The dataframe will be read directly from Civis without copying the CSV to a local file on disk.

Parameters:
file_idint

ID of a Civis File which contains a CSV

return_asstr, {“pandas”, “polars”}

Return a pandas.DataFrame instance if "pandas" is provided, or a polars.DataFrame instance for "polars". Default: "pandas".

compressionstr, optional

(Only active if return_as is "pandas".) If “infer”, set the compression argument of pandas.read_csv() based on the file extension of the name of the Civis File. Otherwise pass this argument to pandas.read_csv().

clientcivis.APIClient, optional

If not provided, an civis.APIClient object will be created from the CIVIS_API_KEY.

**read_kwargs

Additional arguments will be passed directly to read_csv() or polars.read_csv().

Returns:
DataFrame or polars.DataFrame
Raises:
ImportError

If return_as is "pandas" and pandas is not installed. If return_as is "polars" and polars is not installed.

See also

pandas.read_csv