How to open a compressed file in gz format ?
    sharkloc 
    dswew4er at qq.com
       
    Mon Mar 15 01:36:08 UTC 2021
    
    
  
I want to read the content(file.gz) line by line,the following 
code is not friendly to large files of hundreds of Gb, and the 
memory overhead is also very large.
import std.stdio;
import std.process;
import std.string;
void main(string[] args){
	string fileName = args[1];
	string command = "gzip -dc " ~ fileName ;
	auto dmd = executeShell(command);
	if(dmd.status != 0){
		writeln("Compilation failed:\n", dmd.output);
	}
	else{
		auto all=chomp(dmd.output).split("\n");
	    writeln(typeid(all));
	    for(int i=0; i<all.length; i++){
		    writeln(all[i]);
		}
	}
}
    
    
More information about the Digitalmars-d-learn
mailing list