leaf_focus/pdf/info/item.py
def load_csv(cls, path: Path):
        """Load info items from a file."""
        if not path:
            raise ValueError("Must provide path.")
        if path.suffix.lower() != ".csv":
            raise ValueError("Must be a csv file.")

        with open(path, "rt", encoding="utf8") as f:
            reader = csv.DictReader(f)

            items = {}
            for row in reader:
                pdf_path = row.get("pdf_path")
                key = row.get("key")
                value = row.get("value")
                if pdf_path not in items:
                    items[pdf_path] = {}
                items[pdf_path][key] = value

            for pdf_path, entries in items.items():
                yield Item(pdf_path=Path(pdf_path), entries=entries)
Load info items from a file.
Load info items from a file.
Load info items from a file .
def load_csv(cls, path: Path):
        if not path:
            raise ValueError("Must provide path.")
        if path.suffix.lower() != ".csv":
            raise ValueError("Must be a csv file.")
        with open(path, "rt", encoding="utf8") as f:
            reader = csv.DictReader(f)
            items = {}
            for row in reader:
                pdf_path = row.get("pdf_path")
                key = row.get("key")
                value = row.get("value")
                if pdf_path not in items:
                    items[pdf_path] = {}
                items[pdf_path][key] = value
            for pdf_path, entries in items.items():
                yield Item(pdf_path=Path(pdf_path), entries=entries)
def load_csv ( cls , path : Path ) : if not path : raise ValueError ( "Must provide path." ) if path . suffix . lower ( ) != ".csv" : raise ValueError ( "Must be a csv file." ) with open ( path , "rt" , encoding = "utf8" ) as f : reader = csv . DictReader ( f ) items = { } for row in reader : pdf_path = row . get ( "pdf_path" ) key = row . get ( "key" ) value = row . get ( "value" ) if pdf_path not in items : items [ pdf_path ] = { } items [ pdf_path ] [ key ] = value for pdf_path , entries in items . items ( ) : yield Item ( pdf_path = Path ( pdf_path ) , entries = entries )
Load info items from a file.
Load info items from a file .
"""Load info items from a file."""
cls
path
Path