Created
January 15, 2013 06:28
-
-
Save emhart/4536646 to your computer and use it in GitHub Desktop.
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
''' | |
import csv | |
open("test.csv","w").close() | |
dat = ['one potato','two potato'] | |
dat2 = ['3 potato','four'] | |
dat3 = ['8 potatos','9 potatoes'] | |
mydat = [dat,dat2,dat3] | |
with open("test.csv","a") as csvfile: | |
mywriter = csv.writer(csvfile, delimiter=",") | |
for x in mydat: | |
mywriter.writerow(x) | |
''' | |
import time | |
import csv | |
#def data | |
dat = [] | |
for x in range(500000): | |
dat.append(["8times"] * 5) | |
start = time.time() | |
open("test.csv","w").close() | |
with open("test.csv","a") as csvfile: | |
mywriter = csv.writer(csvfile, delimiter=",") | |
for x in dat: | |
mywriter.writerow(x) | |
print (time.time() - start) | |
start = time.time() | |
open("test.csv","w").close() | |
for x in range(500000): | |
with open("test.csv","a") as csvfile: | |
mywriter = csv.writer(csvfile, delimiter=",") | |
mywriter.writerow(dat[x]) | |
print (time.time() - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment