如何在google colab中提取rar文件

dhr*_*rot 6 python ubuntu rar google-colaboratory

在 google 驱动器中有一个数据集,我想在google colab 中使用。但我无法以任何方式解压rar 文件。到目前为止,我已经尝试安装 python 库和 ubuntu 包,如“unrar ,rar,unrar-free ,unar ,unp”,我就是无法打开该死的文件。以下是每个命令的结果:

!rar x 数据.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
Run Code Online (Sandbox Code Playgroud)

!unrar 资料.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
Run Code Online (Sandbox Code Playgroud)

!unp元数据.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!
Run Code Online (Sandbox Code Playgroud)

其他人都没有工作,因此欢迎任何想法。

小智 6

以下代码片段对我有用:

get_ipython().system_raw("unrar x file_name")
Run Code Online (Sandbox Code Playgroud)


Sri*_*ghu 6

!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')
Run Code Online (Sandbox Code Playgroud)

查看此代码片段

真的很简单而且超级快


Aru*_*run 5

以下代码片段对我有用:

!pip install unrar
!unrar x file_path
Run Code Online (Sandbox Code Playgroud)


dhr*_*rot -3

从那时起,我尝试了很多解决方案,但最好的解决方案是使用“rsync”Linux 命令(使用“!apt install rsync”安装 rsync)然后“unzip”命令将文件从驱动器获取到协作存储。之后速度快如闪电(71.32MB/s)。