i'm trying to read sasdataset using pyreadstat directly from sftp server, as i couldn't download the data, i'm trying this approach:
import pysftp
class My_Connection(pysftp.Connection):
def __init__(self, *args, **kwargs):
try:
if kwargs.get('cnopts') is not None:
return
kwargs['cnopts'] = pysftp.CnOpts()
kwargs['cnopts'].hostkeys = None
except pysftp.HostKeysException as e:
self._init_error = True
print('Warning Failed to load Host-keys')
else:
self._init_error = False
self._sftp_live = False
self._transport = None
super().__init__(*args, **kwargs)
def __del__(self):
if not self._init_error:
self.close()
with My_Connection(SFTP_HOST,username=SFTP_USER,password=SFTP_PASSWORD,) as conn:
conn.cwd('/sas/sasdata/sasdev/sasdatasets')
with open("/sas/sasdata/sasdev/sasdatasets/statfile.sas7bdat", 'r') as fp:
df = pyreadstat.read_sas7bdat(fp)
can anyone help me how we can read sasdataset directly in server, when file size is big?