from huggingface_hub import hf_hub_download, HfApi import pandas as pd import os api = HfApi() commits = api.list_repo_commits(repo_id='toecm/IEDID', repo_type='dataset') valid_commit = next((c for c in commits if '9bd61a137a86' in c.commit_id), None) if valid_commit: for filename in ['Nigerian Pidgin English.csv', 'Asụsụ Igbo.csv']: try: print(f"Restoring {filename}...") path = hf_hub_download(repo_id='toecm/IEDID', filename=filename, repo_type='dataset', revision=valid_commit.commit_id) df = pd.read_csv(path) print(f"Loaded {filename} with {len(df)} rows.") # Save it local_path = f"restored_{filename.replace(' ', '_')}" df.to_csv(local_path, index=False) # Upload back to HF api.upload_file( path_or_fileobj=local_path, path_in_repo=filename, repo_id='toecm/IEDID', repo_type='dataset', commit_message=f"Restore {filename} before bug truncation" ) print(f"Successfully restored {filename} to HF Hub") except Exception as e: print(f"Failed to restore {filename}: {e}")