Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _7z_from_kaggle(self):
import subprocess
try:
import kaggle
except OSError as e:
raise OSError(
f""""
Need to provide Kaggle credentials to download this data set. See guide at
https://github.com/Kaggle/kaggle-api#api-credentials.
"""
)
files = ['train', 'transactions', 'members_v3']
print('Downloading from Kaggle...')
for file in files:
kaggle.api.competition_download_file('kkbox-churn-prediction-challenge', file + '.csv.7z',
path=self._path_dir, force=True)
for file in files:
print(f"Extracting '{file}'...")
subprocess.check_output(['7z', 'x', str(self._path_dir / (file + '.csv.7z')),
f"-o{self._path_dir}"])
print(f"Finished extracting '{file}'.")