Dump option
This commit is contained in:
parent
c1807e0d70
commit
354bf1a1ff
|
@ -28,6 +28,7 @@ import argparse
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description="Parse Hubspot Contacts CSV Export")
|
parser = argparse.ArgumentParser(description="Parse Hubspot Contacts CSV Export")
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--csv",
|
"--csv",
|
||||||
|
@ -35,20 +36,33 @@ def parse_args():
|
||||||
type=str,
|
type=str,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-d",
|
||||||
|
"--dump",
|
||||||
|
help="Dump CSV contents",
|
||||||
|
action="store_true",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return 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():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
CSV = args.csv
|
CSV = args.csv
|
||||||
|
|
||||||
print("Parsing" + CSV)
|
print("Parsing" + CSV)
|
||||||
|
|
||||||
with open(CSV, newline="") as csvfile:
|
if args.dump:
|
||||||
contactreader = csv.reader(csvfile, delimiter=",", quotechar='"')
|
dump_csv(CSV)
|
||||||
for row in contactreader:
|
|
||||||
print(", ".join(row))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue