Skip to content

Instantly share code, notes, and snippets.

@mickaellegal
Created June 16, 2014 09:31
Show Gist options
  • Save mickaellegal/e17e4924aff15e14e500 to your computer and use it in GitHub Desktop.
Save mickaellegal/e17e4924aff15e14e500 to your computer and use it in GitHub Desktop.
Python: Handle ragged csv files
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