Skip to content

Instantly share code, notes, and snippets.

@gurgeh
Last active September 27, 2016 07:08
Show Gist options
  • Save gurgeh/bd101552beaafc21f7af8ce543f9fb7f to your computer and use it in GitHub Desktop.
Save gurgeh/bd101552beaafc21f7af8ce543f9fb7f to your computer and use it in GitHub Desktop.
import csv
import os
def add_all(path, prefix):
rows = []
first = True
for fname in os.listdir(path):
if fname.startswith(prefix):
with open(os.path.join(path, fname)) as inf: # join path and filename
c = csv.reader(inf)
if not first: # remove header from every file, but the first
c.next() # remove header
first = False
rows.extend(c)
return rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment