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

Hello everyone,
in the tabular data model I can download the 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 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'):, '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 See here for when it disappeared in favor of fastdownload:

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


Thanks a lot @pwh . It worked