# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_read.ipynb.

# %% auto 0
__all__ = ['csv_file', 'read_csv', 'save_csv']

# %% ../nbs/01_read.ipynb 4
from importlib_resources import files, as_file
from pathlib import Path
import pandas as pd
from nlit import EXT_CSV

# %% ../nbs/01_read.ipynb 6
def csv_file(name: str, resource_path: str = 'csvs') -> Path:
     import phn
     file = files(phn).joinpath(resource_path, name).with_suffix(EXT_CSV)
     return file

# %% ../nbs/01_read.ipynb 7
def read_csv(name: str, resource_path: str = 'csvs'):
     file = csv_file(name, resource_path)
     with as_file(file) as f: return pd.read_csv(f)

# %% ../nbs/01_read.ipynb 9
def save_csv(df: pd.DataFrame, name: str, resource_path: str = 'csvs'):
     file = csv_file(name, resource_path)
     df.to_csv(file, index=False)
