Esempio n. 1
0
parser.add_argument('-f',
                    '--force',
                    help='Overwrites existing output file if present',
                    type=bool)
args = parser.parse_args()
print(args)

# Check for optional outcsv argument. Use default if not present.
if args.outcsv is None:
    outcsv = './normalized.csv'
else:
    outcsv = args.outcsv

# Reject missing file with reasonable feedback
if os.path.isfile(args.csv) is not True:
    sys.exit(''.join(('Error: ', args.csv,
                      ' not found. Please provide a valid CSV file path.')))

# If -f is used and file outcsv already exists delete it
if os.path.isfile(outcsv) is True:
    os.remove(outcsv)

# Parse CSV and replace bad values with proper ones (normalizing)
norm = Normalizer()
if outcsv is None:
    norm.parse_file(args.csv)
else:
    norm.parse_file(args.csv, outcsv)

#end
print('Complete.')