1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2024-12-22 12:12:18 +01:00

csv_metadata_quality/app.py: Handle Ctrl-C

Instead of printing an ugly two-page stack trace.
This commit is contained in:
Alan Orth 2019-08-03 21:11:57 +03:00
parent a00d3d7ea5
commit f4e7fd73f5
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -4,6 +4,8 @@ import csv_metadata_quality.check as check
import csv_metadata_quality.fix as fix import csv_metadata_quality.fix as fix
import pandas as pd import pandas as pd
import re import re
import signal
import sys
def parse_args(argv): def parse_args(argv):
@ -18,9 +20,16 @@ def parse_args(argv):
return args return args
def signal_handler(signal, frame):
sys.exit(1)
def run(argv): def run(argv):
args = parse_args(argv) args = parse_args(argv)
# set the signal handler for SIGINT (^C)
signal.signal(signal.SIGINT, signal_handler)
# Read all fields as strings so dates don't get converted from 1998 to 1998.0 # Read all fields as strings so dates don't get converted from 1998 to 1998.0
df = pd.read_csv(args.input_file, dtype=str) df = pd.read_csv(args.input_file, dtype=str)