Skip to content

Instantly share code, notes, and snippets.

@miguelmalvarez
Created January 31, 2015 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmalvarez/4ef13b9f196c7aa6991e to your computer and use it in GitHub Desktop.
Save miguelmalvarez/4ef13b9f196c7aa6991e to your computer and use it in GitHub Desktop.
def read_csv(file_path, has_header = True):
with open(file_path) as f:
if has_header: f.readline()
data = []
for line in f:
line = line.strip().split(",")
data.append([float(x) for x in line])
return data
def write_csv(file_path, data):
with open(file_path,"w") as f:
for line in data: f.write(",".join(line) + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment