Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b69cc7c

Browse filesBrowse files
committed
Merge pull request matplotlib#1699 from gatagat/fix_csv2rec_comments
Enable to switch off the removal of comments in csv2rec.
2 parents bad102e + faa5c85 commit b69cc7c
Copy full SHA for b69cc7c

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed

‎lib/matplotlib/mlab.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mlab.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
21092109
files is automatic, if the filename ends in '.gz'
21102110
21112111
- *comments*: the character used to indicate the start of a comment
2112-
in the file
2112+
in the file, or *None* to switch off the removal of comments
21132113
21142114
- *skiprows*: is the number of rows from the top to skip
21152115
@@ -2274,7 +2274,7 @@ def get_converters(reader):
22742274
if needheader:
22752275
for row in reader:
22762276
#print 'csv2rec', row
2277-
if len(row) and row[0].startswith(comments):
2277+
if len(row) and comments is not None and row[0].startswith(comments):
22782278
continue
22792279
headers = row
22802280
break
@@ -2317,7 +2317,7 @@ def get_converters(reader):
23172317
while 1:
23182318
# skip past any comments and consume one line of column header
23192319
row = next(reader)
2320-
if len(row) and row[0].startswith(comments):
2320+
if len(row) and comments is not None and row[0].startswith(comments):
23212321
continue
23222322
break
23232323

@@ -2326,8 +2326,10 @@ def get_converters(reader):
23262326
rows = []
23272327
rowmasks = []
23282328
for i, row in enumerate(reader):
2329-
if not len(row): continue
2330-
if row[0].startswith(comments): continue
2329+
if not len(row):
2330+
continue
2331+
if comments is not None and row[0].startswith(comments):
2332+
continue
23312333
# Ensure that the row returned always has the same nr of elements
23322334
row.extend([''] * (len(converters) - len(row)))
23332335
rows.append([func(name, val) for func, name, val in zip(converters, names, row)])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.