Running 09_tabular.ipynb in colab cannot run 'file_extract'

Hello everyone,
in the tabular data model I can download the bluebook-for-bulldozers.zip into Path(’/root/.fastai/archive/bluebook’), but using file_extract to unzip it gives the following error:

I am running it in colab. I used the same code about 6 months ago, and it used to work well. Is it something about new updates in fast.ai library?

Thank you for your help

@babak.jfard, I ran into this error too. Here’s how I worked around it:

  • If anything exists at ~/.fastai/archive/bluebook/, delete it.
  • Restart your notebook.
  • Immediately before the cell where you get the error, add a new cell with this code and execute it:
def file_extract(fname, dest=None):
     "Extract `fname` to `dest` using `tarfile` or `zipfile`."
     if dest is None: dest = Path(fname).parent
     fname = str(fname)
     if   fname.endswith('gz'):  tarfile.open(fname, 'r:gz').extractall(dest)
     elif fname.endswith('zip'): zipfile.ZipFile(fname     ).extractall(dest)
     else: raise Exception(f'Unrecognized archive: {fname}')

:point_up: This is the code from the old file_extract function in fastai.data.external. See here for when it disappeared in favor of fastdownload:

Now, you should be able to work through the notebook as usual.

4 Likes

Thanks a lot @pwh . It worked