How do I import zip files from HF to colab
I am trying to import my data to DFL_Colab. I extracted and cleaned up the data when I attempted to use DFL locally then I uploaded the data to HF. I dont know how any of this works so I tried copying and pasting a number of things.NotebookLinkCell code:`#@titleImport from URL{ form-width: “30%”, display->mode: “form” }URL = >“https://huggingface.co/NexViolentus/MyStuff/blob/main/>data_dst.zip”  #@param{type:“string”}Mode = “unzip to content” #@param[“unzip to content”, “unzip to content/workspace”, “unzip to content/workspace/data_src”, “unzip to content/workspace/data_src/aligned”, “unzip to content/workspace/data_dst”, “unzip to content/workspace/data_dst/aligned”, “unzip to content/workspace/model”, “download to content/workspace”]import urllib.requestfrom pathlib import Pathdef unzip(zip_path, dest_path):unzip_cmd = " unzip -q " + zip_path + " -d "+dest_path!$unzip_cmdrm_cmd = "rm "+dest_path + url_path.name!$rm_cmdprint(“Unziped!”)if Mode == “unzip to content”:dest_path = “/content/”elif Mode == “unzip to content/workspace”:dest_path = “/content/workspace/”elif Mode == “unzip to content/workspace/data_src”:dest_path = “/content/workspace/data_src/”elif Mode == “unzip to content/workspace/data_src/aligned”:dest_path = “/content/workspace/data_src/aligned/”elif Mode == “unzip to content/workspace/data_dst”:dest_path = “/content/workspace/data_dst/”elif Mode == “unzip to content/workspace/data_dst/aligned”:dest_path = “/content/workspace/data_dst/aligned/”elif Mode == “unzip to content/workspace/model”:dest_path = “/content/workspace/model/”elif Mode == “download to content/workspace”:dest_path = “/content/workspace/”if not Path(“/content/workspace”).exists():cmd = “mkdir /content/workspace; mkdir /content/workspace/data_src; mkdir /content/workspace/data_src/aligned; mkdir /content/workspace/data_dst; mkdir /content/workspace/data_dst/aligned; mkdir /content/workspace/model”!$cmdurl_path = Path(URL)urllib.request.urlretrieve ( URL, dest_path + url_path.name )if (url_path.suffix == “.zip”) and (Mode!=“download to content/workspace”):unzip(dest_path + url_path.name, dest_path)print(“Done!”)`‘I get some variation of the errors below. I tried usermane:password@url, making it public, installing transformers. If this doesnt work on colab at all is there another notebook I could use?’Errors:'HTTPError                                 Traceback (most recent call last)in <cell line: 40>()3839 url_path = Path(URL)—> 40 urllib.request.urlretrieve ( URL, dest_path + url_path.name )4142 if (url_path.suffix == “.zip”) and (Mode!=“download to content/workspace”):6 frames/usr/lib/python3.10/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)641 class HTTPDefaultErrorHandler(BaseHandler):642     def http_error_default(self, req, fp, code, msg, hdrs):→ 643         raise HTTPError(req.full_url, code, msg, hdrs, fp)644645 class HTTPRedirectHandler(BaseHandler):HTTPError: HTTP Error 401: Unauthorized’
2023-05-29T06:22:12Z
if anyone is googling this here is what worked for me!pip install huggingface_hubfrom huggingface_hub import REDACTED_TOKEN_downloadfrom huggingface_hub import loginlogin(token=“REDACTED_TOKEN”)REDACTED_TOKEN_download(repo_id=“username/repository”,filename=“data_src.zip”)#importthe file or repository!git clonehttp://huggingface.co/username/repository#thisconverts the zip to a usable format!zip -FF path/to/zipfile --output path/to/output/zip#unzipthe file!unzip path/to/your/zip