@@ -2092,7 +2092,7 @@ def extract(r):
2092
2092
2093
2093
def csv2rec (fname , comments = '#' , skiprows = 0 , checkrows = 0 , delimiter = ',' ,
2094
2094
converterd = None , names = None , missing = '' , missingd = None ,
2095
- use_mrecords = False ):
2095
+ use_mrecords = False , dayfirst = False , yearfirst = False ):
2096
2096
"""
2097
2097
Load data from comma/space/tab delimited file in *fname* into a
2098
2098
numpy record array and return the record array.
@@ -2131,6 +2131,14 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
2131
2131
2132
2132
- *use_mrecords*: if True, return an mrecords.fromrecords record array if any of the data are missing
2133
2133
2134
+ - *dayfirst*: default is False so that MM-DD-YY has precedence over
2135
+ DD-MM-YY. See http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
2136
+ for further information.
2137
+
2138
+ - *yearfirst*: default is False so that MM-DD-YY has precedence over
2139
+ YY-MM-DD. See http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
2140
+ for further information.
2141
+
2134
2142
If no rows are found, *None* is returned -- see :file:`examples/loadrec.py`
2135
2143
"""
2136
2144
@@ -2218,7 +2226,7 @@ def mybool(x):
2218
2226
2219
2227
def mydate (x ):
2220
2228
# try and return a date object
2221
- d = dateparser (x )
2229
+ d = dateparser (x , dayfirst = dayfirst , yearfirst = yearfirst )
2222
2230
2223
2231
if d .hour > 0 or d .minute > 0 or d .second > 0 :
2224
2232
raise ValueError ('not a date' )
0 commit comments