2

I first create the file (appending mode)

db.to_csv(DB, mode='a', header=False, sep='\t')

then I try to open it:

rdb=pd.read_table(DB,sep="\t",header=True,parse_dates=True)

And next, Python crashes,probably because the file is open, is not it?

I have tried: db.close() but does not work

user3446097
  • 21
  • 1
  • 1
  • 3
  • It would help if you would post a short, complete, stand-alone program that demonstrates your error. From your description, I should think a 10-line program would suffice. See http://SSCCE.org and http://stackoverflow.com/help/mcve – Robᵩ Mar 21 '14 at 14:58

1 Answers1

2

I'm late to answer here, but for anyone else having this problem, I found the answer here:

Closing file after using to_csv()

You can pass to_csv a file object instead of just a path, and then close it yourself, like this:

outfile = open(path+'filename.csv', 'wb')
df.to_csv(outfile)
outfile.close()  
Community
  • 1
  • 1
rossdavidh
  • 1,966
  • 2
  • 22
  • 33