@@ -2109,7 +2109,7 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
2109
2109
files is automatic, if the filename ends in '.gz'
2110
2110
2111
2111
- *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
2113
2113
2114
2114
- *skiprows*: is the number of rows from the top to skip
2115
2115
@@ -2274,7 +2274,7 @@ def get_converters(reader):
2274
2274
if needheader :
2275
2275
for row in reader :
2276
2276
#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 ):
2278
2278
continue
2279
2279
headers = row
2280
2280
break
@@ -2317,7 +2317,7 @@ def get_converters(reader):
2317
2317
while 1 :
2318
2318
# skip past any comments and consume one line of column header
2319
2319
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 ):
2321
2321
continue
2322
2322
break
2323
2323
@@ -2326,8 +2326,10 @@ def get_converters(reader):
2326
2326
rows = []
2327
2327
rowmasks = []
2328
2328
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
2331
2333
# Ensure that the row returned always has the same nr of elements
2332
2334
row .extend (['' ] * (len (converters ) - len (row )))
2333
2335
rows .append ([func (name , val ) for func , name , val in zip (converters , names , row )])
0 commit comments