diff --git a/hsparse/parse_csv_contacts.py b/hsparse/parse_csv_contacts.py index 7995399..a10177b 100644 --- a/hsparse/parse_csv_contacts.py +++ b/hsparse/parse_csv_contacts.py @@ -44,6 +44,13 @@ def parse_args(): action="store_true", ) + parser.add_argument( + "-f", + "--fields", + help="Fields from CSV header", + action="store_true", + ) + args = parser.parse_args() return args @@ -54,6 +61,12 @@ def csv_dump(CSV): for row in contactreader: print(", ".join(row)) +def csv_fields(CSV): + with open(CSV, newline="") as csvfile: + contactreader = csv.reader(csvfile, delimiter=",", quotechar='"') + header = next(csvfile) + print(header) + def main(): args = parse_args() @@ -62,6 +75,8 @@ def main(): if args.dump: csv_dump(CSV) + if args.fields: + csv_fields(CSV) if __name__ == "__main__": main()