如何提取带有Zipfile的URL范围的TIFF文件?
我想从一系列URL提取TIF文件。 是不起作用的
此代码适用于一个zip文件,但是如果我想在范围内提取zip(1,43),则该错误
是: badzipfile:文件不是zip文件,
有人可以帮助我吗?
print('Downloading started')
for number in range(1,3):
url = f'https://downloadagiv.blob.core.windows.net/dhm-vlaanderen-ii-dsm-raster-1m/DHMVIIDSMRAS1m_k{number}.zip'
req = requests.get(url)
# Split URL to get the file name
filename = url.split('/')[-1]
req = requests.get(url)
print('Downloading Completed')
zipfile= ZipFile(BytesIO(req.content))
listOfFileNames = zipfile.namelist()
for filename in listOfFileNames:
# Check filename endswith tif
if filename.endswith('.tif'):
# Extract a single file from zip
zipfile.extract(filename, '/content/gdrive/My Drive')
I want to extract the tif file from a range of URL. This code works for one zip file, but if I want to extract zips in a range(1,43) it doesn't work
the error is:
BadZipFile: File is not a zip file
Could somebody help me?
print('Downloading started')
for number in range(1,3):
url = f'https://downloadagiv.blob.core.windows.net/dhm-vlaanderen-ii-dsm-raster-1m/DHMVIIDSMRAS1m_k{number}.zip'
req = requests.get(url)
# Split URL to get the file name
filename = url.split('/')[-1]
req = requests.get(url)
print('Downloading Completed')
zipfile= ZipFile(BytesIO(req.content))
listOfFileNames = zipfile.namelist()
for filename in listOfFileNames:
# Check filename endswith tif
if filename.endswith('.tif'):
# Extract a single file from zip
zipfile.extract(filename, '/content/gdrive/My Drive')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论