From: Rich on
Thanks. This does look promising. Any you say this has performance like the
Jet method? How about the delimiter? can I say

parser.ColumnDelimiter = " ".ToCharArray();

for a space delimiter?


"Jeff Johnson" wrote:

> "Rich" <Rich(a)discussions.microsoft.com> wrote in message
> news:14D7E1BF-0CC5-4ACE-9AE4-93CB128E6C98(a)microsoft.com...
>
> > Any suggestions would be greatly appreciated for an escape sequence for a
> > space delimiter.
>
> I can't stand using Jet for this due to its reliance on schema.ini. (Really,
> an .INI file? What century are we in...?)
>
> I recommend this library:
> http://www.codeproject.com/KB/database/GenericParser.aspx. It needs some
> work when it comes to fixed-width files, but it's great for delimited, and
> that's what you need.
>
>
> .
>
From: Peter Duniho on
Rich wrote:
> Thanks. This does look promising. Any you say this has performance like the
> Jet method? How about the delimiter? can I say
>
> parser.ColumnDelimiter = " ".ToCharArray();
>
> for a space delimiter?

I can't answer the parser-specific aspect (though, seems like that's
something you could just try), but if you can do the above, wouldn't you
prefer this instead:

parser.ColumnDelimiter = new char[] { ' ' };

?

Why create a whole string instance only to just turn around and then
create a new array based on it, when you can just create the array directly?

Pete
From: Jeff Johnson on
"Rich" <Rich(a)discussions.microsoft.com> wrote in message
news:2DB0310C-A555-4615-985A-996FEC7B1082(a)microsoft.com...

> Thanks. This does look promising. Any you say this has performance like
> the
> Jet method?

The performance is spectacular. I've never done any side-by-side
comparisons, but I know this thing is fast.


From: Rich on
I started experimenting with this sample project. I noticed that stream
reader is being used here, along with a creation of a schema.ini file like
the Jet technique. It looks to me like the Jet technique wraps up all of its
coding to a one liner - where the Jet underlying code is probably simlar to
the code being used in this sample. And I guess the benefit with the code in
this sample is that can be modified where the Jet code can't.

The downside with this sample - for me - is the learning curve. I will have
to study this a bit. And then once I compile the class I would have to
reference it - adding a dependency to my project.

It looks - for the time being - I will resign myself to my elementary usage
of StreamReader. The Jet technique would be nice because it is a one liner,
but alas! it does not seem to support a space as a delimiter.


"Jeff Johnson" wrote:

> "Rich" <Rich(a)discussions.microsoft.com> wrote in message
> news:14D7E1BF-0CC5-4ACE-9AE4-93CB128E6C98(a)microsoft.com...
>
> > Any suggestions would be greatly appreciated for an escape sequence for a
> > space delimiter.
>
> I can't stand using Jet for this due to its reliance on schema.ini. (Really,
> an .INI file? What century are we in...?)
>
> I recommend this library:
> http://www.codeproject.com/KB/database/GenericParser.aspx. It needs some
> work when it comes to fixed-width files, but it's great for delimited, and
> that's what you need.
>
>
> .
>
From: Jeff Johnson on
"Rich" <Rich(a)discussions.microsoft.com> wrote in message
news:0448AEE2-5E52-4228-B5A2-581206EB802A(a)microsoft.com...

>I started experimenting with this sample project. I noticed that stream
> reader is being used here, along with a creation of a schema.ini file like
> the Jet technique. It looks to me like the Jet technique wraps up all of
> its
> coding to a one liner - where the Jet underlying code is probably simlar
> to
> the code being used in this sample. And I guess the benefit with the code
> in
> this sample is that can be modified where the Jet code can't.
>
> The downside with this sample - for me - is the learning curve. I will
> have
> to study this a bit. And then once I compile the class I would have to
> reference it - adding a dependency to my project.
>
> It looks - for the time being - I will resign myself to my elementary
> usage
> of StreamReader. The Jet technique would be nice because it is a one
> liner,
> but alas! it does not seem to support a space as a delimiter.

....learning curve? It should be about as simple as

TextParserAdapter parser = new
TextParserAdapter(@"<path>\SpaceDelimFile.txt");
parser.ColumnDelimiter = new char[] { ' ' };

DataTable dt = parser.GetDataTable();

And then you just work with the data in the DataTable like you would with
data from any other data source. Now I've made a lot of modifications to
that library over time, but I think the code I have right there should work
out-of-the-box.