Last active
November 23, 2015 20:25
-
-
Save Jwely/9ad6aaf89b2d0fb1f5ef to your computer and use it in GitHub Desktop.
write_list_to_csv.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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