MCPcopy
hub / github.com/pandas-dev/pandas / _read_strls

Method _read_strls

pandas/io/stata.py:1550–1578  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1548 self._value_labels_read = True
1549
1550 def _read_strls(self) -> None:
1551 self._path_or_buf.seek(self._seek_strls)
1552 # Wrap v_o in a string to allow uint64 values as keys on 32bit OS
1553 self.GSO = {"0": ""}
1554 while True:
1555 if self._path_or_buf.read(3) != b"GSO":
1556 break
1557
1558 if self._format_version == 117:
1559 v_o = self._read_uint64()
1560 else:
1561 buf = self._path_or_buf.read(12)
1562 # Only tested on little endian machine.
1563 v_size = 2 if self._format_version == 118 else 3
1564 if self._byteorder == "<":
1565 buf = buf[0:v_size] + buf[4 : (12 - v_size)]
1566 else:
1567 buf = buf[4 - v_size : 4] + buf[(4 + v_size) :]
1568 v_o = struct.unpack(f"{self._byteorder}Q", buf)[0]
1569 typ = self._read_uint8()
1570 length = self._read_uint32()
1571 va = self._path_or_buf.read(length)
1572 if typ == 130:
1573 decoded_va = va[0:-1].decode(self._encoding)
1574 else:
1575 # Stata says typ 129 can be binary, so use str
1576 decoded_va = str(va)
1577 # Wrap v_o in a string to allow uint64 values as keys on 32bit OS
1578 self.GSO[str(v_o)] = decoded_va
1579
1580 def __next__(self) -> DataFrame:
1581 self._using_iterator = True

Callers 1

readMethod · 0.95

Calls 6

_read_uint64Method · 0.95
_read_uint8Method · 0.95
_read_uint32Method · 0.95
decodeMethod · 0.80
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected