Parsing and splitting textfile
Justin Whear
justin at economicmodeling.com
Mon Feb 24 11:08:16 PST 2014
On Mon, 24 Feb 2014 14:00:09 -0500, Steven Schveighoffer wrote:
> On Mon, 24 Feb 2014 13:52:45 -0500, Hugo Florentino <hugo at acdam.cu>
> wrote:
>
>> Hello,
>>
>> Can you point me to an efficient way to parse a text file and split it
>> by certain expression (for example, `\n\nFrom\ .+ at .+$`), copying what
>> has already been read to a separate file, and so on till the end of the
>> file?
>>
>> I am trying to implement a mailbox to maildir format conversion
>> application in D, but I would like to avoid loading each mbox
>> completely into memory.
>>
>> Regards, Hugo
>
> std.regex
>
> -Steve
Specifically std.regex.splitter[1] creates a lazy range over the input.
You can couple this with lazy file reading (e.g. `File("mailbox").byChunk
(1024).joiner`).
Justin
More information about the Digitalmars-d-learn
mailing list