@@ -91,7 +91,7 @@ def read_csv(filepath_or_buffer, sep=',', header=0, index_col=None, names=None,
91
91
skiprows = None , na_values = None , parse_dates = False ,
92
92
date_parser = None , nrows = None , iterator = False , chunksize = None ,
93
93
skip_footer = 0 , converters = None , verbose = False , delimiter = None ,
94
- encoding = None ):
94
+ encoding = None , infer_index = True ):
95
95
if hasattr (filepath_or_buffer , 'read' ):
96
96
f = filepath_or_buffer
97
97
else :
@@ -117,7 +117,8 @@ def read_csv(filepath_or_buffer, sep=',', header=0, index_col=None, names=None,
117
117
skip_footer = skip_footer ,
118
118
converters = converters ,
119
119
verbose = verbose ,
120
- encoding = encoding )
120
+ encoding = encoding ,
121
+ infer_index = infer_index )
121
122
122
123
if nrows is not None :
123
124
return parser .get_chunk (nrows )
@@ -204,6 +205,8 @@ class TextParser(object):
204
205
Number of line at bottom of file to skip
205
206
encoding : string, default None
206
207
Encoding to use for UTF when reading/writing (ex. 'utf-8')
208
+ infer_index : boolean, default True
209
+ If index_col is None, will try to infer index unless this is False
207
210
"""
208
211
209
212
# common NA values
@@ -217,7 +220,7 @@ def __init__(self, f, delimiter=None, names=None, header=0,
217
220
index_col = None , na_values = None , parse_dates = False ,
218
221
date_parser = None , chunksize = None , skiprows = None ,
219
222
skip_footer = 0 , converters = None , verbose = False ,
220
- encoding = None ):
223
+ encoding = None , infer_index = True ):
221
224
"""
222
225
Workhorse function for processing nested list into DataFrame
223
226
@@ -234,7 +237,7 @@ def __init__(self, f, delimiter=None, names=None, header=0,
234
237
self .chunksize = chunksize
235
238
self .passed_names = names is not None
236
239
self .encoding = encoding
237
-
240
+ self . infer_index = infer_index
238
241
239
242
if com .is_integer (skiprows ):
240
243
skiprows = range (skiprows )
@@ -401,7 +404,7 @@ def _get_index_name(self):
401
404
return line
402
405
403
406
if implicit_first_cols > 0 :
404
- if self .index_col is None :
407
+ if self .index_col is None and self . infer_index :
405
408
if implicit_first_cols == 1 :
406
409
self .index_col = 0
407
410
else :
0 commit comments