How to extract rar files inside google colab
Solution 1
I have tried lots of solutions since then, but the best one has been to get the file from drive to collab's storage using "rsync" Linux command (install rsync using "!apt install rsync") and then "unzip" command. It is lightning fast after that (71.32MB/s).
Solution 2
The following code snippet worked for me:
!pip install unrar
!unrar x file_path
Solution 3
The following code snippet worked for me:
get_ipython().system_raw("unrar x file_name")
Solution 4
!pip install pyunpack
!pip install patool
from pyunpack import Archive
Archive('Location of the rar file').extractall('Location where you want to have the folder')
Check out this code snippet
Really simple and super fast
Related videos on Youtube
dhrumil barot
AI researcher| psych fan| existentialist| emotionless unbiased robot |workoholic| introvert reader∆ I love data😍😍
Updated on January 31, 2021Comments
-
dhrumil barot over 3 years
I have a dataset in google drive which I want to use in google colab.But I can't unrar the rar files by any means.So far I have tried installing python libraries and also ubuntu packages like "unrar ,rar ,unrar-free ,unar ,unp" and I just can't open the damn file.Here are the results of each command:
!rar x data.rar
RAR 5.40 Copyright (c) 1993-2016 Alexander Roshal 15 Aug 2016 Trial version Type RAR -? for help Extracting from meta-data.rar Cannot create meta-data/sample_submission.csv No such file or directory Cannot create meta-data/test.csv No such file or directory Cannot create meta-data/train.csv No such file or directory Cannot create directory meta-data Input/output error Total errors: 4
!unrar data.rar
UNRAR 5.50 freeware Copyright (c) 1993-2017 Alexander Roshal Extracting from meta-data.rar Cannot create meta-data/sample_submission.csv No such file or directory Cannot create meta-data/test.csv No such file or directory Cannot create meta-data/train.csv No such file or directory Cannot create directory meta-data Input/output error Total errors: 4
!unp meta-data.rar
RAR 5.40 Copyright (c) 1993-2016 Alexander Roshal 15 Aug 2016 Trial version Type RAR -? for help Extracting from meta-data.rar Cannot create meta-data/sample_submission.csv No such file or directory Cannot create meta-data/test.csv No such file or directory Cannot create meta-data/train.csv No such file or directory Cannot create directory meta-data Input/output error Total errors: 4 UNRAR 5.50 freeware Copyright (c) 1993-2017 Alexander Roshal Extracting from meta-data.rar Cannot create meta-data/sample_submission.csv No such file or directory Cannot create meta-data/test.csv No such file or directory Cannot create meta-data/train.csv No such file or directory Cannot create directory meta-data Input/output error Total errors: 4 Can't exec "file": No such file or directory at /usr/bin/unp line 419. Failed to detect file type of meta-data.rar. WARNING: There were errors while processing files!
None of the others a re working either so any ideas are welcomed.
-
Kirushikesh over 2 yearsI think no need to give the path inside double quotes.