diff --git a/pfbudget/cli/argparser.py b/pfbudget/cli/argparser.py index cb2ba13..276e004 100644 --- a/pfbudget/cli/argparser.py +++ b/pfbudget/cli/argparser.py @@ -60,11 +60,12 @@ def argparser() -> argparse.ArgumentParser: # init = subparsers.add_parser("init") # init.set_defaults(op=Operation.Init) - # Exports transactions to .csv file + # Exports transactions to specified format and file export = subparsers.add_parser("export") export.set_defaults(op=Operation.Export) file_options(export) + # Imports transactions from specified format and file pimport = subparsers.add_parser("import") pimport.set_defaults(op=Operation.Import) file_options(pimport) diff --git a/pfbudget/common/types.py b/pfbudget/common/types.py index 0f50d5f..8b8c0e5 100644 --- a/pfbudget/common/types.py +++ b/pfbudget/common/types.py @@ -52,7 +52,6 @@ class Operation(Enum): class ExportFormat(Enum): - CSV = auto() JSON = auto() pickle = auto() diff --git a/pfbudget/core/command.py b/pfbudget/core/command.py index 0d01e92..f1c4903 100644 --- a/pfbudget/core/command.py +++ b/pfbudget/core/command.py @@ -1,5 +1,4 @@ from abc import ABC, abstractmethod -import csv import json from pathlib import Path import pickle @@ -29,9 +28,6 @@ class ExportCommand(Command): def execute(self) -> None: values = self.__client.select(self.what) match self.format: - case ExportFormat.CSV: - with open(self.fn, "w", newline="") as f: - csv.writer(f).writerows([serialize(e) for e in values]) case ExportFormat.JSON: with open(self.fn, "w", newline="") as f: json.dump([serialize(e) for e in values], f, indent=4, default=str) diff --git a/pfbudget/core/manager.py b/pfbudget/core/manager.py index a9ef5d5..c968527 100644 --- a/pfbudget/core/manager.py +++ b/pfbudget/core/manager.py @@ -1,4 +1,3 @@ -import csv import json from pathlib import Path import pickle @@ -363,9 +362,6 @@ class Manager: if format == "pickle": with open(fn, "wb") as f: pickle.dump([e.format for e in sequence], f) - elif format == "csv": - with open(fn, "w", newline="") as f: - csv.writer(f).writerows([e.format.values() for e in sequence]) elif format == "json": with open(fn, "w", newline="") as f: json.dump([e.format for e in sequence], f, indent=4, default=str) @@ -377,8 +373,6 @@ class Manager: if format == "pickle": with open(fn, "rb") as f: return pickle.load(f) - elif format == "csv": - raise Exception("CSV import not supported") else: print("format not well specified") return []