Borrar filtros
Borrar filtros

To delete gunziped file

3 visualizaciones (últimos 30 días)
Pooja
Pooja el 2 de Sept. de 2014
Editada: Stephen23 el 2 de Sept. de 2014
I am using gunzip to get the unzipped file from .gz file. I need that I get data from the unzipped file and don't get a copy of unzipped file. This is because unzipped file take a lot of space and I have 1000s of such file. i.e. I want to delete the unzipped file as soon as I get required data from it. OR Is there any way to get only required data from .gz file.
Thanks in advance Pooja
  2 comentarios
Stephen23
Stephen23 el 2 de Sept. de 2014
The basic function for deleting files is delete .
But it is not clear what you are actually trying to do. Are you doing this in a loop? In what form is your list of filenames? Do you generate the filenames on the fly? Where are the files located?
We need to know a bit more about what you are doing, in order to have an idea of how to solve your problem.
Please read this advice on how to write a question that will make it easier for people to help you, then edit your question to provide a minimum working example of your code.
Pooja
Pooja el 2 de Sept. de 2014
Thanks for replying. I tried to use delete. But it gave the following error
delete(file) Warning: File not found or permission denied
The part of the code is as follow
fil_nme='I:\GOES_DATA\G13\RETSD_MODMD_G13_GEC_2010171_21_gfsTfg_regWfg.gz; f=gunzip(fil_nme); file=char(f); f1=fopen(file,'r'); val=fread(f1,'float32'); delete(file);
gunzip(fil_nme) is creating the unzipped file with the same name in the same folder. I don't want to keep this file once I extract the required data. But delete(file) gave the error as
Warning: File not found or permission denied
Please help me to resolve the problem. I have already google it, but didn't get the answer. Thanks

Iniciar sesión para comentar.

Respuesta aceptada

Guillaume
Guillaume el 2 de Sept. de 2014
You need to close the file before deleting it. Write
fclose(file);
before
delete(file);
  2 comentarios
Pooja
Pooja el 2 de Sept. de 2014
fclose('all'); delete(file); worked Thankyou very much
Stephen23
Stephen23 el 2 de Sept. de 2014
Editada: Stephen23 el 2 de Sept. de 2014
It is a good idea to keep fopen and fclose calls very close to each other, to avoid eaxctly this kind of problem: basically as soon as you write fopen you should write the following fclose too. And keep only the bare minimum amount of code in between, usually reading/writing whatever data is required.
Note that fclose('all') could cause problems if this function is called from another function that has and requires an open file...

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by