leaf_focus/pdf/info/item.py
def save_csv(cls, path: Path, items: list["Item"]):
        """Save info items to a file."""
        if not path:
            raise ValueError("Must provide path.")
        if path.suffix.lower() != ".csv":
            raise ValueError("Must be a csv file.")

        fields = ["pdf_path", "key", "value"]
        with open(path, "wt", newline="", encoding="utf8") as f:
            writer = csv.DictWriter(f, fields)
            writer.writeheader()
            for i in items:
                for k, v in i.entries.items():
                    writer.writerow(
                        {"pdf_path": str(i.pdf_path), "key": str(k), "value": str(v)}
                    )
Save info items to a file.
Save info items to a file.
Save info items to a file .
def save_csv(cls, path: Path, items: list["Item"]):
        if not path:
            raise ValueError("Must provide path.")
        if path.suffix.lower() != ".csv":
            raise ValueError("Must be a csv file.")
        fields = ["pdf_path", "key", "value"]
        with open(path, "wt", newline="", encoding="utf8") as f:
            writer = csv.DictWriter(f, fields)
            writer.writeheader()
            for i in items:
                for k, v in i.entries.items():
                    writer.writerow(
                        {"pdf_path": str(i.pdf_path), "key": str(k), "value": str(v)}
                    )
def save_csv ( cls , path : Path , items : list [ "Item" ] ) : if not path : raise ValueError ( "Must provide path." ) if path . suffix . lower ( ) != ".csv" : raise ValueError ( "Must be a csv file." ) fields = [ "pdf_path" , "key" , "value" ] with open ( path , "wt" , newline = "" , encoding = "utf8" ) as f : writer = csv . DictWriter ( f , fields ) writer . writeheader ( ) for i in items : for k , v in i . entries . items ( ) : writer . writerow ( { "pdf_path" : str ( i . pdf_path ) , "key" : str ( k ) , "value" : str ( v ) } )
Save info items to a file.
Save info items to a file .
"""Save info items to a file."""
cls
path
Path
items
list["Item"]