Created
June 16, 2014 09:31
-
-
Save mickaellegal/e17e4924aff15e14e500 to your computer and use it in GitHub Desktop.
Python: Handle ragged csv files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import csv | |
file = "YOUR_FILE_PATH" | |
# Read the csv with python | |
lines=list(csv.reader(open(file))) | |
# Get the name of the columns | |
head, val = lines[0], lines[1:] | |
# Transform it to a pandas dataframe | |
df = pd.read_csv(file, names=head) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment