Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95948

Re: continue vs. pass in this IO reading and writing

References <19ca6361-95fe-4a5d-84d6-c72d7941745c@googlegroups.com> <mailman.70.1441294042.8327.python-list@python.org> <53c5301c-2833-446f-a7d1-6c0ef9314928@googlegroups.com>
Date 2015-09-04 01:51 +1000
Subject Re: continue vs. pass in this IO reading and writing
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.75.1441295521.8327.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Sep 4, 2015 at 1:38 AM, kbtyo <ahlusar.ahluwalia@gmail.com> wrote:
> Thank you for the elaboration. So, what I hear you saying is that (citing, "In this case, there's no further body, so it's going to be the same as "pass" (which
> means "do nothing")") that the else block is not entered. For exma

Seems like a cut-off paragraph here, but yes. In a try/except/else
block, the 'else' block executes only if the 'try' didn't raise an
exception of the specified type(s).

> Do you mind elaborating on what you meant by "compatible headers?". The files that I am processing may or may not have the same headers (but if they do they should add the respective values only).
>

Your algorithm is basically: Take the entire first file, including its
header, and then append all other files after skipping their first
lines. If you want a smarter form of CSV merge, I would recommend
using the 'csv' module, and probably doing a quick check of all files
before you begin, so as to collect up the full set of headers. That'll
also save you the hassle of playing around with StopIteration as you
read in the headers.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

continue vs. pass in this IO reading and writing kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-09-03 08:05 -0700
  Re: continue vs. pass in this IO reading and writing Chris Angelico <rosuav@gmail.com> - 2015-09-04 01:27 +1000
    Re: continue vs. pass in this IO reading and writing kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-09-03 08:38 -0700
      Re: continue vs. pass in this IO reading and writing Chris Angelico <rosuav@gmail.com> - 2015-09-04 01:51 +1000
        Re: continue vs. pass in this IO reading and writing kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-09-03 08:57 -0700
          Re: continue vs. pass in this IO reading and writing Chris Angelico <rosuav@gmail.com> - 2015-09-04 02:11 +1000
            Re: continue vs. pass in this IO reading and writing kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-09-03 09:35 -0700
    Re: continue vs. pass in this IO reading and writing kbtyo <ahlusar.ahluwalia@gmail.com> - 2015-09-03 08:49 -0700
  Re: continue vs. pass in this IO reading and writing Terry Reedy <tjreedy@udel.edu> - 2015-09-03 12:05 -0400
  Re: continue vs. pass in this IO reading and writing Luca Menegotto <otlucaDELETE@DELETEyahoo.it> - 2015-09-03 18:37 +0200

csiph-web