Read and write gzip files easily.

nazriel spam at dzfl.pl
Wed Feb 19 10:19:43 PST 2014


On Wednesday, 19 February 2014 at 15:51:53 UTC, Kamil Slowikowski 
wrote:
> Hi there, I'm new to D and have a lot of learning ahead of me. 
> It would
> be extremely helpful to me if someone with D experience could 
> show me
> some code examples.
>
> I'd like to neatly read and write gzipped files for my work. I 
> have read
> several threads on these forums on the topic of std.zlib or 
> std.zip and I haven't been able to figure it out.
>
> Here's a Python script that does what I want. Can you please 
> show me
> an example in D that does the same thing?
>
> <code>
> #!/usr/bin/env python
>
> import gzip
>
> # Read a gzipped file and print the contents line by line.
> with gzip.open("input.gz") as stream:
>     for line in stream:
>         print line
>
> # Write some text to a gzipped file.
> with gzip.open("output.gz", "w") as stream:
>     stream.write("some output goes here\n")
> </code>
>
>
> I have a second request. I would like to start using D more in 
> my work,
> and in particular I would like to use and extend the BioD 
> library. Artem
> Tarasov made a nice module to handle BGZF, and I would like to 
> see an
> example like my Python code above using Artem's module.
>
> Read more about BGZF:
> http://blastedbio.blogspot.com/2011/11/bgzf-blocked-bigger-better-gzip.html
>
> BioD:
> https://github.com/biod/BioD/blob/d2bea0a0da63eb820fcf11ae367456b2c367ec04/bio/core/bgzf/compress.d

Witaj Kamil :)

Feel free to also visit #d channel on freenode IRC network.


More information about the Digitalmars-d mailing list