I have hundreds of .tar.gz files that come in a landing zone. The below python snippet runs on a schedule to extract these files and write the contents in another directory.
import tarfile
for f in files:
with tarfile.open(f) as uncompressed_file:
uncompressed_file.extractall(outfile_path)
I receive the following error for some files, but it stops the remaining files from being processed.
EOFError: Compressed file ended before the end-of-stream marker was reached
Is there an try/except block I can use that will let me skip the error files and proceed to extract the remaining files?
This will catch your error: