Dump option
This commit is contained in:
parent
c1807e0d70
commit
354bf1a1ff
|
@ -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__":
|
||||
|
|
Loading…
Reference in a new issue