Created
April 20, 2015 19:45
-
-
Save hayd/22020d3fef347229728b to your computer and use it in GitHub Desktop.
appending to csv
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
def append_frame(f='foo.csv', df=df, keep_open=False, n=1000): | |
if keep_open: | |
with open(f, mode='a') as f_: | |
for i in xrange(n): | |
df.to_csv(f_, mode='a') | |
else: | |
for i in xrange(n): | |
df.to_csv(f, mode='a') | |
os.remove(f) |
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
# Try these for some (increasing values of n): | |
%timeit append_frame(keep_open=True, n=100000) | |
%timeit append_frame(keep_open=False, n=100000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment