简体   繁体   English

如何解压缩传递变量的文件夹?

[英]How to unzip a folder passing a variable?

I am trying to unzip a folder by passing it a variable in Google-colab.我试图通过在 Google-colab 中传递一个变量来解压缩文件夹。 However when I do it, it doesn't show up in my folders.但是,当我这样做时,它不会显示在我的文件夹中。

If I do it by passing it directly the name, like in this answer here: Extract Google Drive zip from Google colab notebook如果我通过直接传递名称来实现,就像这里的答案一样: 从 Google colab notebook 中提取 Google Drive zip

!unzip TASI.zip

I get this output:我得到这个输出:

rchive:  TASI.zip
  inflating: TASI/Output [11-13(1) _good_; 18_06_2019 15_58_09].csv  
  inflating: TASI/Output [11-15(1) _good_; 18_06_2019 15_51_26].csv  
  inflating: TASI/Output [11-46(1) _good_; 18_06_2019 15_41_08].csv  
  inflating: TASI/Output [11-47(1) _good_; 18_06_2019 15_36_31].csv  
  inflating: TASI/Output [3-14(1) _good_; 18_06_2019 14_06_52].csv  
  inflating: TASI/Output [3-18(1) _good_; 18_06_2019 13_55_35].csv  
  inflating: TASI/Output [4-31(1) _bad_; 18_06_2019 14_51_19].csv  

And the folder appears in my colab files.该文件夹出现在我的 colab 文件中。

If I do it by passing it the variable:如果我通过传递变量来做到这一点:

file_folder="TASI.zip"
!unzip -c "$file_folder" 

In the output it shows me the content of every file.在输出中,它显示了每个文件的内容。 And the folder does not appear in the colab files.并且该文件夹不会出现在 colab 文件中。 Output:输出:

Archive:  TASI.zip
  inflating: TASI/Output [11-13(1) _good_; 18_06_2019 15_58_09].csv  

SetupTitle, Output
PrimitiveTest, I/V Sweep
TestParameter, Context.MainFrame, 4155C
TestParameter, Channel.UnitType, SMU, SMU, SMU
TestParameter, Channel.Unit, SMU3:MP, SMU4:MP, SMU1:MP
TestParameter, Channel.IName, ID, IS, IG
TestParameter, Channel.VName, VD, VS, VG
TestParameter, Channel.Mode, V, COMMON, V
TestParameter, Channel.Func, VAR1, CONST, VAR2....

How do I unzip the folder in colab passing it a variable?如何在 colab 中解压缩文件夹并传递一个变量?

The -c flag to unzip is defined as extract files to stdout/screen (''CRT'').解压缩的-c标志被定义为将extract files to stdout/screen (''CRT''). the two commands you are running are not the same, in the command where you specifically provide the file name you dont use the -c option so unzip extracts to the filesystem.您正在运行的两个命令是不一样的,在您专门提供文件名的命令中,您不使用 -c 选项,以便解压缩到文件系统。 In the command where you give a variable you use the -c flag telling unzip just to extract the files to the screen.在您提供变量的命令中,您使用 -c 标志告诉解压缩只是将文件解压缩到屏幕上。

Try unzip with the variable but without the -c flag.尝试使用变量解压缩但不使用 -c 标志。

file_folder="TASI.zip"
!unzip "$file_folder" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM