fix clean method
This commit is contained in:
12
main.py
12
main.py
@@ -43,8 +43,11 @@ class JsonToCsv:
|
|||||||
|
|
||||||
def init_db(self):
|
def init_db(self):
|
||||||
self.counter += 1
|
self.counter += 1
|
||||||
self.ts = time.strftime('%Y%m%d_%H%M%S', time.localtime())
|
self.ts = time.strftime('%Y%m%d-%H%M%S', time.localtime())
|
||||||
self.con = sqlite3.connect(args.output / f"data-{args.name}-{self.ts}-{self.counter}.db")
|
db_name = args.output / f"data-{args.name}-{self.ts}-{self.counter}.db"
|
||||||
|
if args.verbose > 0:
|
||||||
|
print(f"creating DB {db_name}")
|
||||||
|
self.con = sqlite3.connect(db_name)
|
||||||
self.cur = self.con.cursor()
|
self.cur = self.con.cursor()
|
||||||
self.make_tables()
|
self.make_tables()
|
||||||
|
|
||||||
@@ -266,15 +269,14 @@ class JsonToCsv:
|
|||||||
make_archive(args.output, pathlib.Path(f"{top_level}.zip"))
|
make_archive(args.output, pathlib.Path(f"{top_level}.zip"))
|
||||||
|
|
||||||
|
|
||||||
json_csv = JsonToCsv()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if args.verbose >= 1:
|
if args.verbose >= 1:
|
||||||
print(f"args = {args}")
|
print(f"args = {args}")
|
||||||
|
|
||||||
if args.clean:
|
if args.clean:
|
||||||
for d in args.output.glob("*.csv"):
|
for d in args.output.iterdir():
|
||||||
print(f"will delete {d}")
|
print(f"will delete {d}")
|
||||||
os.unlink(d)
|
os.unlink(d)
|
||||||
|
|
||||||
|
json_csv = JsonToCsv()
|
||||||
json_csv.parse_json()
|
json_csv.parse_json()
|
||||||
|
|||||||
Reference in New Issue
Block a user