I am trying to extract some .csv files from gz (compressed) files. I want to delete the rows in the excel file that are blank. I am using the code below but it does not work :
$entoli = 'zcat ' . str_replace(' ', '\ ', $filePath) . ' | sed \'/^\s*$/d\' > ' . str_replace(' ', '\ ', $savePath);
exec($entoli);
where $filePath
is the directory of the original compressed and $savePath
is the directory where the extracted file will be saved. Also, I am using str_replace(' ', '\ ', ....)
just in case there are spaces in the path.
I used this code before in order to delete the rows that do not start with the date format and it works :
$entoli = 'zcat ' . str_replace(' ', '\ ', $filePath) . ' | sed \'/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/!d\' > ' . str_replace(' ', '\ ', $savePath);
exec($entoli);
so, I presume that only this line has to be changed :
sed \'/^\s*$/d\'