Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57990
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jcasale@activenetwerx.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.044 |
| X-Spam-Evidence | '*H*': 0.92; '*S*': 0.01; 'stops': 0.07; 'subject:code': 0.07; 'subject:file': 0.07; 'input,': 0.09; "subject:, '": 0.09; 'received:172.18.0': 0.16; 'subject: \n ': 0.16; 'to:name:python-list@python.org': 0.22; 'header:In-Reply- To:1': 0.27; 'wondering': 0.29; "i'm": 0.30; 'file': 0.32; 'checking': 0.33; 'subject:the': 0.34; 'subject:with': 0.35; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'skip:o 20': 0.38; 'subject:new': 0.38; 'conditions.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'received:unknown': 0.61; 'subject:Using': 0.84; 'opens': 0.91; 'race': 0.95 |
| X-Cloudmark-SP-Filtered | true |
| X-Cloudmark-SP-Result | v=1.1 cv=/24PZDiXryEUsaYH72AX4ulVzqSXihAXfE7Ql5lDP0I= c=1 sm=1 a=AgG5ixNBvo4A:10 a=XJDAhjgDJnYA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=u8e7-jQaOBxZnvlltpUA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 |
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: Using "with open(filename, 'ab'):" and calling code only if the file is new? |
| Thread-Topic | Using "with open(filename, 'ab'):" and calling code only if the file is new? |
| Thread-Index | AQHO1Q0NHudcB+MlkkSnceEwY5yRgpoMeBnw |
| Date | Wed, 30 Oct 2013 01:42:50 +0000 |
| References | <68bd6cb6-44b2-446c-b0e2-043e3ac1c35b@googlegroups.com> |
| In-Reply-To | <68bd6cb6-44b2-446c-b0e2-043e3ac1c35b@googlegroups.com> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [172.18.0.201] |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1783.1383097380.18130.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1383097380 news.xs4all.nl 15884 [2001:888:2000:d::a6]:56719 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:57990 |
Show key headers only | View raw
> with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as > output: > fieldnames = (...) > csv_writer = DictWriter(output, filednames) > # Call csv_writer.writeheader() if file is new. > csv_writer.writerows(my_dict) > > I'm wondering what's the best way of calling writeheader() only if the file is > new? > > My understanding is that I don't want to use os.path.exist(), since that opens > me up to race conditions. What stops you from checking before and setting a flag?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using "with open(filename, 'ab'):" and calling code only if the file is new? Victor Hooi <victorhooi@gmail.com> - 2013-10-29 18:02 -0700
RE: Using "with open(filename, 'ab'):" and calling code only if the file is new? "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-10-30 01:42 +0000
RE: Using "with open(filename, 'ab'):" and calling code only if the file is new? Dave Angel <davea@davea.name> - 2013-10-30 02:13 +0000
RE: Using "with open(filename, 'ab'):" and calling code only if the file is new? "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-10-30 02:55 +0000
Re: Using "with open(filename, 'ab'):" and calling code only if the file is new? Victor Hooi <victorhooi@gmail.com> - 2013-10-29 20:22 -0700
Fwd: Using "with open(filename, 'ab'):" and calling code only if the file is new? Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-10-29 22:28 -0500
Re: Using "with open(filename, 'ab'):" and calling code only if the file is new? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 08:53 +0100
Re: Using "with open(filename, 'ab'):" and calling code only if the file is new? Neil Cerutti <neilc@norwich.edu> - 2013-10-30 13:23 +0000
csiph-web