Skip to content

Instantly share code, notes, and snippets.

@Jwely
Last active November 23, 2015 20:25
Show Gist options
  • Save Jwely/9ad6aaf89b2d0fb1f5ef to your computer and use it in GitHub Desktop.
Save Jwely/9ad6aaf89b2d0fb1f5ef to your computer and use it in GitHub Desktop.
write_list_to_csv.py
# super barebones list to csv
list = ["some", "kind", "of", "data"]
with open("myfile.csv", "w+") as f:
for item in list:
f.write(str(item) + "\n")
# same deal but with lists of lists
list_of_lists = [["bob", "20"],
["joe", "24"],
["bro", "19"]]
with open("myfile.csv", "w+") as f:
for alist in list_of_lists:
f.write(",".join(map(str,alist)) + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment