hostelallocation / upload_seed_data.py
PrathameshRaut's picture
Create upload_seed_data.py
27cf91a verified
Raw
History Blame Contribute Delete
1.03 kB
"""
Run this ONCE to seed the HF dataset repo with hostel_vacancy.xlsx.
Usage:
pip install huggingface_hub
python upload_seed_data.py \
--token hf_xxxx \
--repo yourusername/hostel-data \
--file /path/to/hostel_vacancy.xlsx
"""
import argparse
from huggingface_hub import HfApi
def main():
p = argparse.ArgumentParser()
p.add_argument("--token", required=True)
p.add_argument("--repo", required=True, help="dataset repo id, e.g. user/hostel-data")
p.add_argument("--file", default="hostel_vacancy.xlsx")
args = p.parse_args()
api = HfApi()
# Create repo if it doesn't exist
api.create_repo(repo_id=args.repo, repo_type="dataset", exist_ok=True, token=args.token)
api.upload_file(
path_or_fileobj=args.file,
path_in_repo="hostel_vacancy.xlsx",
repo_id=args.repo,
repo_type="dataset",
token=args.token,
)
print(f"✅ Uploaded {args.file}{args.repo}/hostel_vacancy.xlsx")
if __name__ == "__main__":
main()