Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62167 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2013-12-17 09:55 +0100 |
| Last post | 2013-12-17 09:55 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Reading csv file Peter Otten <__peter__@web.de> - 2013-12-17 09:55 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2013-12-17 09:55 +0100 |
| Subject | Re: Reading csv file |
| Message-ID | <mailman.4270.1387270513.18130.python-list@python.org> |
Peter Otten wrote: > You are still reading the complete csv file. Assuming > > (1) the first row of the csv contains the column names > (2) you want to skip the first five rows of data > > you'd have to write > > reader = csv.Reader(file) Sorry, I meant DictReader, not Reader. > line = 0 > while line < 5: > next(reader) > line += 1 > for row in reader: > .... # process csv row > > A simpler alternative is to use itertools.islice(): > > for row in itertools.islice(reader, 5, None): > ... # process csv row
Back to top | Article view | comp.lang.python
csiph-web