Output CSV fields nicer
This commit is contained in:
parent
d1c9de1066
commit
61d67961ee
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
""" Read CSV contacts file exported from hubspot."""
|
""" Read CSV contacts file exported from hubspot."""
|
||||||
|
|
||||||
import csv
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import csv
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description="Parse Hubspot Contacts CSV Export")
|
parser = argparse.ArgumentParser(description="Parse Hubspot Contacts CSV Export")
|
||||||
|
@ -56,16 +56,13 @@ def parse_args():
|
||||||
|
|
||||||
|
|
||||||
def csv_dump(CSV):
|
def csv_dump(CSV):
|
||||||
with open(CSV, newline="") as csvfile:
|
df = pd.read_csv(CSV, low_memory=False)
|
||||||
contactreader = csv.reader(csvfile, delimiter=",", quotechar='"')
|
print(df)
|
||||||
for row in contactreader:
|
|
||||||
print(", ".join(row))
|
|
||||||
|
|
||||||
def csv_fields(CSV):
|
def csv_fields(CSV):
|
||||||
with open(CSV, newline="") as csvfile:
|
df = pd.read_csv(CSV, low_memory=False, header=0)
|
||||||
contactreader = csv.reader(csvfile, delimiter=",", quotechar='"')
|
print("\n".join([col for col in df.columns]))
|
||||||
header = next(csvfile)
|
|
||||||
print(header)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -78,5 +75,6 @@ def main():
|
||||||
if args.fields:
|
if args.fields:
|
||||||
csv_fields(CSV)
|
csv_fields(CSV)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue