Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74286
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Writing Python File at Specific Interval |
| Date | 2014-07-09 23:51 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lpkkh5$kj$1@dont-email.me> (permalink) |
| References | <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> |
On Wed, 09 Jul 2014 07:36:49 -0700, subhabangalore wrote: > The code (a basic crawler) would run every morning or evening, on a > predefined time. [This part is fine]. > > In the next part, I am trying to store the daily results to a new file. So what you want to do is store each day's results in a new file, so probably you want to create a filename that looks something like an iso 8601 date. Luckily for you python has this functionality available: https://docs.python.org/2/library/datetime.html#date-objects $ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import date >>> fn = date.today().isoformat() + ".log" >>> print fn 2014-07-10.log >>> quit() $ Once you have a string containing your filename, you might use: fp = open( fn, "w" ) fp.write( data ) fp.close() -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Writing Python File at Specific Interval subhabangalore@gmail.com - 2014-07-09 07:36 -0700
Re:Writing Python File at Specific Interval Dave Angel <davea@davea.name> - 2014-07-09 14:55 -0400
Re: Writing Python File at Specific Interval Shubham Tomar <tomarshubham24@gmail.com> - 2014-07-09 22:47 +0530
Re: Writing Python File at Specific Interval Abhiram R <abhi.darkness@gmail.com> - 2014-07-09 23:09 +0530
Re: Writing Python File at Specific Interval Denis McMahon <denismfmcmahon@gmail.com> - 2014-07-09 23:51 +0000
Re: Writing Python File at Specific Interval subhabangalore@gmail.com - 2014-07-20 04:15 -0700
Re: Writing Python File at Specific Interval Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-20 12:46 +0100
csiph-web