Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Created February 5, 2020 16:39
Show Gist options
  • Save kyleparisi/678daf95c5d0306e97e05f47d57e915e to your computer and use it in GitHub Desktop.
Save kyleparisi/678daf95c5d0306e97e05f47d57e915e to your computer and use it in GitHub Desktop.
import csv
import os
from types import SimpleNamespace
from utils.logging import logger
PROJECT_PATH = os.path.abspath(os.path.dirname(__name__))
def run():
logger.info(f"Reading CSV")
path = f"{PROJECT_PATH}/data.csv"
number_of_rows = len(open(path).readlines()) - 1
with open(path, newline="") as csvfile:
rows = csv.DictReader(csvfile)
row_counter = 0
logger.info(f"Processing {number_of_rows} rows")
for row in rows:
row_counter += 1
logger.info(f"Processed {row_counter}/{number_of_rows} rows")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment