[Deprecate] CSV export/import removed
CSV is not a good format, since it does not have a good support for complex types, e.g. lists. It served when the exported format was only a linear transaction, but it is not worth the extra work around it anymore.
This commit is contained in:
parent
a527fa5e1d
commit
6057ec59b4
@ -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)
|
||||
|
||||
@ -52,7 +52,6 @@ class Operation(Enum):
|
||||
|
||||
|
||||
class ExportFormat(Enum):
|
||||
CSV = auto()
|
||||
JSON = auto()
|
||||
pickle = auto()
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user