Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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