【发布时间】:2016-08-22 15:30:27
【问题描述】:
我正在尝试使用 Python 脚本从 HDFS 导入 tar.gz 文件,然后解压缩它。文件如下20160822073413-EoRcGvXMDIB5SVenEyD4pOEADPVPhPsg.tar.gz,结构相同。
在我的 python 脚本中,我想将它复制到本地并提取文件。我正在使用以下命令来执行此操作:
import subprocess
import os
import datetime
import time
today = time.strftime("%Y%m%d")
#Copy tar file from HDFS to local server
args = ["hadoop","fs","-copyToLocal", "/locationfile/" + today + "*"]
p=subprocess.Popen(args)
p.wait()
#Untar the CSV file
args = ["tar","-xzvf",today + "*"]
p=subprocess.Popen(args)
p.wait()
导入工作完美,但我无法提取文件,我收到以下错误:
['tar', '-xzvf', '20160822*.tar']
tar (child): 20160822*.tar: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
put: `reportResults.csv': No such file or directory
谁能帮帮我?
非常感谢!
【问题讨论】: