mirror of
https://github.com/ilri/csv-metadata-quality.git
synced 2024-11-17 19:47:03 +01:00
csv_metadata_quality/app.py: rework exclude/skip
Instead of processing the excludes inside the for column loop we do it once before and then only need to check if the current column is in the list.
This commit is contained in:
parent
2e489fc921
commit
1f76247353
@ -76,16 +76,16 @@ def run(argv):
|
||||
# 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)
|
||||
|
||||
for column in df.columns:
|
||||
# Check if the user requested to skip any fields
|
||||
if args.exclude_fields:
|
||||
skip = False
|
||||
# Split the list of excludes on ',' so we can test exact matches
|
||||
# rather than fuzzy matches with regexes or "if word in string"
|
||||
for exclude in args.exclude_fields.split(","):
|
||||
if column == exclude and skip is False:
|
||||
skip = True
|
||||
if skip:
|
||||
# Split the list of excluded fields on ',' into a list. Note that the
|
||||
# user should be careful to no include spaces here.
|
||||
exclude = args.exclude_fields.split(",")
|
||||
else:
|
||||
exclude = list()
|
||||
|
||||
for column in df.columns:
|
||||
if column in exclude:
|
||||
print(f"{Fore.YELLOW}Skipping {Fore.RESET}{column}")
|
||||
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user