Skip to content

SAS7BDAT parser: Drop unused instance variables #48764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 3 additions & 44 deletions pandas/io/sas/sas7bdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class SAS7BDATReader(ReaderBase, abc.Iterator):
Return SAS7BDATReader object for iterations, returns chunks
with given number of lines.
encoding : str, 'infer', defaults to None
String encoding acc. to python standard encodings,
String encoding acc. to Python standard encodings,
encoding='infer' tries to detect the encoding from the file header,
encoding=None will leave the data in binary format.
convert_text : bool, defaults to True
Expand Down Expand Up @@ -242,10 +242,8 @@ def _get_properties(self) -> None:
raise ValueError("magic number mismatch (not a SAS file?)")

# Get alignment information
align1, align2 = 0, 0
buf = self._read_bytes(const.align_1_offset, const.align_1_length)
if buf == const.u64_byte_checker_value:
align2 = const.align_2_value
self.U64 = True
self._int_length = 8
self._page_bit_offset = const.page_bit_offset_x64
Expand All @@ -258,7 +256,8 @@ def _get_properties(self) -> None:
buf = self._read_bytes(const.align_2_offset, const.align_2_length)
if buf == const.align_1_checker_value:
align1 = const.align_2_value
total_align = align1 + align2
else:
align1 = 0

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

# Get platform information
buf = self._read_bytes(const.platform_offset, const.platform_length)
if buf == b"1":
self.platform = "unix"
elif buf == b"2":
self.platform = "windows"
else:
self.platform = "unknown"

self.name = self._read_and_convert_header_text(
const.dataset_offset, const.dataset_length
)

self.file_type = self._read_and_convert_header_text(
const.file_type_offset, const.file_type_length
)

# Timestamp is epoch 01/01/1960
epoch = datetime(1960, 1, 1)
x = self._read_float(
Expand All @@ -319,29 +301,6 @@ def _get_properties(self) -> None:
self._page_length = self._read_int(
const.page_size_offset + align1, const.page_size_length
)
self._page_count = self._read_int(
const.page_count_offset + align1, const.page_count_length
)

self.sas_release_offset = self._read_and_convert_header_text(
const.sas_release_offset + total_align, const.sas_release_length
)

self.server_type = self._read_and_convert_header_text(
const.sas_server_type_offset + total_align, const.sas_server_type_length
)

self.os_version = self._read_and_convert_header_text(
const.os_version_number_offset + total_align, const.os_version_number_length
)

self.os_name = self._read_and_convert_header_text(
const.os_name_offset + total_align, const.os_name_length
)
if not self.os_name:
self.os_name = self._read_and_convert_header_text(
const.os_maker_offset + total_align, const.os_maker_length
)

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