From 354bf1a1ff9258f544ff73e824f5ddec656cdc25 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Thu, 19 Sep 2024 12:39:37 -0600 Subject: [PATCH] Dump option --- hsparse/parse_csv_contacts.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hsparse/parse_csv_contacts.py b/hsparse/parse_csv_contacts.py index 5a19d97..e9a8104 100644 --- a/hsparse/parse_csv_contacts.py +++ b/hsparse/parse_csv_contacts.py @@ -28,6 +28,7 @@ import argparse def parse_args(): parser = argparse.ArgumentParser(description="Parse Hubspot Contacts CSV Export") + parser.add_argument( "-c", "--csv", @@ -35,20 +36,33 @@ def parse_args(): type=str, required=True, ) + + parser.add_argument( + "-d", + "--dump", + help="Dump CSV contents", + action="store_true", + ) + args = parser.parse_args() return args +def dump_csv(CSV): + with open(CSV, newline="") as csvfile: + contactreader = csv.reader(csvfile, delimiter=",", quotechar='"') + for row in contactreader: + print(", ".join(row)) + + def main(): args = parse_args() CSV = args.csv print("Parsing" + CSV) - with open(CSV, newline="") as csvfile: - contactreader = csv.reader(csvfile, delimiter=",", quotechar='"') - for row in contactreader: - print(", ".join(row)) + if args.dump: + dump_csv(CSV) if __name__ == "__main__":