File size: 1,033 Bytes
27cf91a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
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()