Sorted files to make sure they are processed in the right order

Rafael
Rafael M. Martins 7 months ago
parent 739aee5d89
commit 6cd615fb94
  1. 5
      py/import.py

@ -20,7 +20,9 @@ for hus_name in next(os.walk(BASEDIR))[1]:
cur = con.cursor()
cards = []
for txt in glob.glob(f"{BASEDIR+hus_name}/**/*.TXT", recursive=True):
all_txts = sorted(glob.glob(f"{BASEDIR+hus_name}/**/*.TXT", recursive=True))
#print(all_txts)
for txt in all_txts:
card, year, month = os.path.split(txt)[1].split('.')[0].split('-')
@ -101,7 +103,6 @@ for hus_name in next(os.walk(BASEDIR))[1]:
# Sometimes, some of the lines in a file are the wrong size.
# When that happens, we skip the file.
if len(data[-1]) != len(col_names):
print(" - Invalid file format; SKIPPING!", len(data[-1]), len(col_names))
continue
placeholder = f"({','.join('?' for _ in range(len(data[0])))})"

Loading…
Cancel
Save