Skip to content

Instantly share code, notes, and snippets.

@brandontlocke
Last active June 5, 2019 15:29
Show Gist options
  • Save brandontlocke/6c33c729fb45118b5b1d03de845e0eb4 to your computer and use it in GitHub Desktop.
Save brandontlocke/6c33c729fb45118b5b1d03de845e0eb4 to your computer and use it in GitHub Desktop.
Create text files from csv
import csv
f = open('filename.csv', 'rU')
csv_f = csv.reader(f)
for row in csv_f:
#this creates the file and names it the contents of the first column
file = open(row[0]+".txt", "w")
#this writes the content from the second column
file.write(row[1])
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment