Skip to content

Commit ff9a1dc

Browse files
authored
SAS7BDAT parser: Drop unused instance variables (#48764)
* SAS7BDAT parser: Drop unused instance variables * Update sas7bdat.py
1 parent 8bcc1eb commit ff9a1dc

File tree

1 file changed

+3
-44
lines changed

1 file changed

+3
-44
lines changed

pandas/io/sas/sas7bdat.py

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class SAS7BDATReader(ReaderBase, abc.Iterator):
138138
Return SAS7BDATReader object for iterations, returns chunks
139139
with given number of lines.
140140
encoding : str, 'infer', defaults to None
141-
String encoding acc. to python standard encodings,
141+
String encoding acc. to Python standard encodings,
142142
encoding='infer' tries to detect the encoding from the file header,
143143
encoding=None will leave the data in binary format.
144144
convert_text : bool, defaults to True
@@ -242,10 +242,8 @@ def _get_properties(self) -> None:
242242
raise ValueError("magic number mismatch (not a SAS file?)")
243243

244244
# Get alignment information
245-
align1, align2 = 0, 0
246245
buf = self._read_bytes(const.align_1_offset, const.align_1_length)
247246
if buf == const.u64_byte_checker_value:
248-
align2 = const.align_2_value
249247
self.U64 = True
250248
self._int_length = 8
251249
self._page_bit_offset = const.page_bit_offset_x64
@@ -258,7 +256,8 @@ def _get_properties(self) -> None:
258256
buf = self._read_bytes(const.align_2_offset, const.align_2_length)
259257
if buf == const.align_1_checker_value:
260258
align1 = const.align_2_value
261-
total_align = align1 + align2
259+
else:
260+
align1 = 0
262261

263262
# Get endianness information
264263
buf = self._read_bytes(const.endianness_offset, const.endianness_length)
@@ -276,23 +275,6 @@ def _get_properties(self) -> None:
276275
else:
277276
self.inferred_encoding = f"unknown (code={buf})"
278277

279-
# Get platform information
280-
buf = self._read_bytes(const.platform_offset, const.platform_length)
281-
if buf == b"1":
282-
self.platform = "unix"
283-
elif buf == b"2":
284-
self.platform = "windows"
285-
else:
286-
self.platform = "unknown"
287-
288-
self.name = self._read_and_convert_header_text(
289-
const.dataset_offset, const.dataset_length
290-
)
291-
292-
self.file_type = self._read_and_convert_header_text(
293-
const.file_type_offset, const.file_type_length
294-
)
295-
296278
# Timestamp is epoch 01/01/1960
297279
epoch = datetime(1960, 1, 1)
298280
x = self._read_float(
@@ -319,29 +301,6 @@ def _get_properties(self) -> None:
319301
self._page_length = self._read_int(
320302
const.page_size_offset + align1, const.page_size_length
321303
)
322-
self._page_count = self._read_int(
323-
const.page_count_offset + align1, const.page_count_length
324-
)
325-
326-
self.sas_release_offset = self._read_and_convert_header_text(
327-
const.sas_release_offset + total_align, const.sas_release_length
328-
)
329-
330-
self.server_type = self._read_and_convert_header_text(
331-
const.sas_server_type_offset + total_align, const.sas_server_type_length
332-
)
333-
334-
self.os_version = self._read_and_convert_header_text(
335-
const.os_version_number_offset + total_align, const.os_version_number_length
336-
)
337-
338-
self.os_name = self._read_and_convert_header_text(
339-
const.os_name_offset + total_align, const.os_name_length
340-
)
341-
if not self.os_name:
342-
self.os_name = self._read_and_convert_header_text(
343-
const.os_maker_offset + total_align, const.os_maker_length
344-
)
345304

346305
def __next__(self) -> DataFrame:
347306
da = self.read(nrows=self.chunksize or 1)

0 commit comments

Comments
 (0)