@@ -833,6 +833,7 @@ def __init__(self, path_or_buf, encoding='iso-8859-1'):
833
833
self ._missing_values = False
834
834
self ._data_read = False
835
835
self ._value_labels_read = False
836
+ self ._native_byteorder = _set_endianness (sys .byteorder )
836
837
if isinstance (path_or_buf , str ):
837
838
path_or_buf , encoding = get_filepath_or_buffer (
838
839
path_or_buf , encoding = self ._default_encoding
@@ -1195,13 +1196,16 @@ def data(self, convert_dates=True, convert_categoricals=True, index=None,
1195
1196
dtype = [] # Convert struct data types to numpy data type
1196
1197
for i , typ in enumerate (self .typlist ):
1197
1198
if typ in self .NUMPY_TYPE_MAP :
1198
- dtype .append (('s' + str (i ), self .NUMPY_TYPE_MAP [typ ]))
1199
+ dtype .append (('s' + str (i ), self .byteorder + self . NUMPY_TYPE_MAP [typ ]))
1199
1200
else :
1200
1201
dtype .append (('s' + str (i ), 'S' + str (typ )))
1201
1202
dtype = np .dtype (dtype )
1202
1203
read_len = count * dtype .itemsize
1203
1204
self .path_or_buf .seek (self .data_location )
1204
1205
data = np .frombuffer (self .path_or_buf .read (read_len ),dtype = dtype ,count = count )
1206
+ # if necessary, swap the byte order to native here
1207
+ if self .byteorder != self ._native_byteorder :
1208
+ data = data .byteswap ().newbyteorder ()
1205
1209
self ._data_read = True
1206
1210
1207
1211
if convert_categoricals :
0 commit comments