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