Error uncompressing gz files

16 visualizaciones (últimos 30 días)
Cian Vaugh
Cian Vaugh el 30 de Abr. de 2021
Editada: Prasanna el 25 de Mayo de 2024
Hi.
im trying to extract data thats areanged in "fileName.dat.gz..tar" form, however, the program seems to crash everytime around the 50th tar file with the error
"Error using matlab.io.internal.archive.core.builtin.uncompressgz
File "TempGz\Filename" is not in GZIP format.
Error in gunzip (line 92)
names = matlab.io.internal.archive.core.builtin.uncompressgz({entries.file}, outputDir);
Error in dataExtractorNimrod5km (line 25)
files = gunzip(untar(MASTERFILE,'TempGz'),'TempDat');"
im 100% sure all the files are gz and it happes accross differnt file collections
any suggestions
the file handeling section can proide more of the script if needed
for i_file = 1:length(fileTarCollection)
%%
disp('day')
disp(i_file)
currentFile = fileTarCollection(i_file); %%...
MASTERFILE = currentFile.name
%%file handeling __________________________________________________________
if PLOT_OUTPUT == true
scrsz = get(0,'ScreenSize');
fh1 = figure('OuterPosition',[1 scrsz(4)*.05 scrsz(3)*0.5 scrsz(4)* 0.95]);
end
disp('Extracting files')
files = gunzip(untar(MASTERFILE,'TempGz'),'TempDat');
NoFiles = length(files);
if PLOT_OUTPUT == true
disp('files extracted')
end

Respuestas (1)

Prasanna
Prasanna el 25 de Mayo de 2024
Editada: Prasanna el 25 de Mayo de 2024
Hi Cian,
The error you're encountering suggests that, during the extraction process, MATLAB encounters a file within your .tar archive that it expects to be in GZIP format but isn't. This could be due to several reasons, including a corrupted file, or a file that's incorrectly named or has a misleading extension. Here are several steps and considerations to help you troubleshoot and resolve the issue:
  • Verify file integrity: Ensure that none of the .tar.gz files are corrupted. You can use tools like gzip -t filename.tar.gz on Linux or macOS to test the integrity of the GZIP files. For Windows, tools like 7-Zip can verify the integrity of compressed files.
  • Manual Test: Try manually extracting the files around the 50th file using external tools (e.g., 7-Zip, WinRAR, or the tar and gzip commands in a Unix-like terminal). This can help verify if the issue is with the file or with the extraction process.
  • Use Lower-Level Functions: If untar and gunzip consistently fail, consider manually managing the extraction process using MATLAB's lower-level file I/O functions. This approach is more complex and requires a good understanding of the GZIP and TAR file formats.
  • Temporary Directory: The error message suggests MATLAB is writing to a "TempGz" directory. Ensure this directory is not filling up or encountering permissions issues partway through your extraction process.
Given the repetitive nature of the task and the consistent failure point, it's likely an issue with how a specific file is being interpreted by extraction functions, or a resource/environmental limitation encountered during the process.
Hope this helps.

Categorías

Más información sobre File Compression en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by