A Few Days of Python: Importing CSV Files

Using the csv module

import csv
f = open('LP_Data.csv')
csv_f = csv.reader(f)

for row in csv_f:
    print row

Using the pandas module

import pandas as pd
df = pd.read_csv("LP_Data.csv")
df.head()

dat = pd.read_csv("LP_Data.csv", iterator=True, chunksize=100)
df = pd.concat(dat, ignore_index=True)
df.head()

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top