From 33f8059f8cf03e40f2da2869c3a31704d74be6cd Mon Sep 17 00:00:00 2001 From: Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> Date: Sun, 23 Jan 2022 00:54:00 +0100 Subject: minor corrections based on actual data --- insert_criminal_records.py | 14 ++++++++------ justice_build.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/insert_criminal_records.py b/insert_criminal_records.py index 02e7788..f4b761b 100644 --- a/insert_criminal_records.py +++ b/insert_criminal_records.py @@ -96,12 +96,14 @@ def insert_crimnal_data_to_DB(c, primary_sql_key, court_records, relevant_paragr else: second_instance = None text_paragraphs = "" - for elem in relevant_paragraphs: - text_paragraphs += elem - text_paragraphs += ", " + if relevant_paragraphs != None: + for elem in relevant_paragraphs: + text_paragraphs += elem + text_paragraphs += ", " text_penalties = "" - for elem in penalties: - text_penalties += elem - text_penalties += ", " + if penalties != None: + for elem in penalties: + text_penalties += elem + text_penalties += ", " c.execute("INSERT INTO criminal_records (company_id, first_instance, second_instance, paragraphs, penalties) VALUES (?, ?, ?, ?, ?)", (primary_sql_key, first_instance, second_instance, text_paragraphs[:-2], text_penalties[:-2],)) return 0 \ No newline at end of file diff --git a/justice_build.py b/justice_build.py index aa092f6..e9ed338 100644 --- a/justice_build.py +++ b/justice_build.py @@ -12,8 +12,8 @@ def main(): # Download commercial register data valid_files = get_valid_filenames() os.makedirs("data", exist_ok=True) - # for valid_file in valid_files: - # download_data(valid_file) + for valid_file in valid_files: + download_data(valid_file) for valid_file in valid_files: modified_file_name = os.path.join(str(os.getcwd()), "data", valid_file + ".xml") update_DB(modified_file_name, DB_name) -- cgit