I am trying to write simple parser, that split text to
key value
name = david
lastname = wood
here is my code:
foreach (line; readText(confname).splitLines())
{
writeln(line);
foreach (str; split(line, "="))
On Friday, 11 May 2012 at 21:13:41 UTC, Paul wrote:
std.utf.UTFException@std\utf.d(644): Invalid UTF-8 sequence (at
index 1)
What are you reading? If it's regular text (0-127) then you
shouldn't have an issue. However 128-255 (or, -1 to -127) are
treated differently. D by default is UTF-8 or
On Friday, 11 May 2012 at 20:43:47 UTC, Era Scarecrow wrote:
On Friday, 11 May 2012 at 20:40:23 UTC, Paul wrote:
On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote:
void main() {
foreach(line; readText("file.in").splitLines()) ...
}
Thanks Jesse.
I'm finding that I can't just sub
On Friday, 11 May 2012 at 20:40:23 UTC, Paul wrote:
On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote:
void main() {
foreach(line; readText("file.in").splitLines()) ...
}
Thanks Jesse.
I'm finding that I can't just substitute args[1] for a text
string. Is there a clever way to
On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote:
On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote:
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote:
On Friday, 11 May 2012 at 18:57:52 UTC, Steven Schveighoffer
wrote:
On Fri, 11 May 2012 11:00:16 -0400, Paul
wrote:
I would like to read a complete file in one statement and
then process it line by line.
foreach (line; MyFile)
e
On Friday, 11 May 2012 at 20:06:45 UTC, Era Scarecrow wrote:
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote:
It sure would. I suspect that Jesse's approach...
readText("file.in").splitLines()
...would be the most efficient way if you need an actual
array: slurp the whole file a
On Friday, 11 May 2012 at 20:06:45 UTC, Era Scarecrow wrote:
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote:
It sure would. I suspect that Jesse's approach...
readText("file.in").splitLines()
...would be the most efficient way if you need an actual
array: slurp the whole file
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote:
It sure would. I suspect that Jesse's approach...
readText("file.in").splitLines()
...would be the most efficient way if you need an actual array:
slurp the whole file at once, then create an array of
memory-sharing slices.
Do
On Friday, 11 May 2012 at 18:57:52 UTC, Steven Schveighoffer
wrote:
On Fri, 11 May 2012 11:00:16 -0400, Paul
wrote:
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Tha
On Fri, 11 May 2012 11:00:16 -0400, Paul wrote:
I would like to read a complete file in one statement and then process
it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
Would something like this work?
auto arr = array(map!"a.idup"(
On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote:
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
If you use the "byLine" approach...
foreach(line; File("myf
On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote:
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
Something like:
import std.file;
import std.string;
void mai
On Friday, 11 May 2012 at 15:18:11 UTC, H. S. Teoh wrote:
On Fri, May 11, 2012 at 05:00:16PM +0200, Paul wrote:
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
import st
On Fri, May 11, 2012 at 05:00:16PM +0200, Paul wrote:
> I would like to read a complete file in one statement and then
> process it line by line.
>
> foreach (line; MyFile)
> etc.
>
> Is it possible to read a file into and array of lines?
import std.array;
import std.stdio;
string[] getLines(Fi
On 05/11/2012 05:00 PM, Paul wrote:
I would like to read a complete file in one statement and then process
it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
---SOURCE
import std.stdio;
import std.file;
int main()
{
writeln("s
I would like to read a complete file in one statement and then
process it line by line.
foreach (line; MyFile)
etc.
Is it possible to read a file into and array of lines?
Thanks
17 matches
Mail list logo