473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

parsing text file into DataTable

I need to parse an third party supplied delimited or fixed width text file
into a datatable. The delimiter may vary.

I am currently using a SteamReader to read each line and, for delimited
files, String.Split() to break each line into an array based on the
delimiter. The problem, as you may guess, is that the delimiter character is
being used in the data

i.e. "Kevin","Williams,"I like commas, I really do"

In the above I get an array with 4 elements and not 3 when the delimiter is
a comma.

My next stop is the Jet OLEDB provider, which expects CSV by default and
which I understand will handle other delimiters with a Schema.ini file.
Seems easy enough...

QUESTION:
Is there a better way than Jet or some .Net class that I am overlooking?

--
kevin...
Jun 14 '06 #1
6 3767
You can use regex..its more powerful.
"kevin" <ke***@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
I need to parse an third party supplied delimited or fixed width text file
into a datatable. The delimiter may vary.

I am currently using a SteamReader to read each line and, for delimited
files, String.Split() to break each line into an array based on the
delimiter. The problem, as you may guess, is that the delimiter character
is
being used in the data

i.e. "Kevin","Williams,"I like commas, I really do"

In the above I get an array with 4 elements and not 3 when the delimiter
is
a comma.

My next stop is the Jet OLEDB provider, which expects CSV by default and
which I understand will handle other delimiters with a Schema.ini file.
Seems easy enough...

QUESTION:
Is there a better way than Jet or some .Net class that I am overlooking?

--
kevin...

Jun 14 '06 #2
Hello Kevin,

Is there any way to use specific symbol as delimiter, not comma?
Problem not in classes but in sentence analysis of you data. You need smth
better to keep info rather than plain text

K> I need to parse an third party supplied delimited or fixed width text
K> file into a datatable. The delimiter may vary.
K>
K> I am currently using a SteamReader to read each line and, for
K> delimited files, String.Split() to break each line into an array
K> based on the delimiter. The problem, as you may guess, is that the
K> delimiter character is being used in the data
K>
K> i.e. "Kevin","Williams,"I like commas, I really do"
K>
K> In the above I get an array with 4 elements and not 3 when the
K> delimiter is a comma.
K>
K> My next stop is the Jet OLEDB provider, which expects CSV by default
K> and which I understand will handle other delimiters with a Schema.ini
K> file. Seems easy enough...
K>
K> QUESTION:
K> Is there a better way than Jet or some .Net class that I am
K> overlooking?
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jun 14 '06 #3
Hi Kevin,

Take a look at opennetcf.org they provide a CSV parser, has you will have
the code you can change (dont remember if this feature is present or not)
the code to instead of "," use any other character you want.

This should be fairly trivial
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
I need to parse an third party supplied delimited or fixed width text file
into a datatable. The delimiter may vary.

I am currently using a SteamReader to read each line and, for delimited
files, String.Split() to break each line into an array based on the
delimiter. The problem, as you may guess, is that the delimiter character
is
being used in the data

i.e. "Kevin","Williams,"I like commas, I really do"

In the above I get an array with 4 elements and not 3 when the delimiter
is
a comma.

My next stop is the Jet OLEDB provider, which expects CSV by default and
which I understand will handle other delimiters with a Schema.ini file.
Seems easy enough...

QUESTION:
Is there a better way than Jet or some .Net class that I am overlooking?

--
kevin...

Jun 14 '06 #4
>>This should be fairly trivial

Thats a bit of an overstatement, isn't it. I found a project on
CodeProject.com and that project is anything but trivial... not overwhelming,
but involved.

http://www.thecodeproject.com/cs/dat...select=1499295

I actually decided to go with the regex solution. I'll first use split and
if that returns and array with an incorrect size (I will know the number of
fields), then I'll use the regex expression.

Thanks for the input
--
kevin...
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi Kevin,

Take a look at opennetcf.org they provide a CSV parser, has you will have
the code you can change (dont remember if this feature is present or not)
the code to instead of "," use any other character you want.

This should be fairly trivial
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
I need to parse an third party supplied delimited or fixed width text file
into a datatable. The delimiter may vary.

I am currently using a SteamReader to read each line and, for delimited
files, String.Split() to break each line into an array based on the
delimiter. The problem, as you may guess, is that the delimiter character
is
being used in the data

i.e. "Kevin","Williams,"I like commas, I really do"

In the above I get an array with 4 elements and not 3 when the delimiter
is
a comma.

My next stop is the Jet OLEDB provider, which expects CSV by default and
which I understand will handle other delimiters with a Schema.ini file.
Seems easy enough...

QUESTION:
Is there a better way than Jet or some .Net class that I am overlooking?

--
kevin...


Jun 15 '06 #5
You can try also with the FileHelpers

http://filehelpers.sourceforge.net/

Best Regards

kevin ha escrito:
This should be fairly trivial


Thats a bit of an overstatement, isn't it. I found a project on
CodeProject.com and that project is anything but trivial... not overwhelming,
but involved.

http://www.thecodeproject.com/cs/dat...select=1499295

I actually decided to go with the regex solution. I'll first use split and
if that returns and array with an incorrect size (I will know the number of
fields), then I'll use the regex expression.

Thanks for the input
--
kevin...
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi Kevin,

Take a look at opennetcf.org they provide a CSV parser, has you will have
the code you can change (dont remember if this feature is present or not)
the code to instead of "," use any other character you want.

This should be fairly trivial
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
I need to parse an third party supplied delimited or fixed width text file
into a datatable. The delimiter may vary.

I am currently using a SteamReader to read each line and, for delimited
files, String.Split() to break each line into an array based on the
delimiter. The problem, as you may guess, is that the delimiter character
is
being used in the data

i.e. "Kevin","Williams,"I like commas, I really do"

In the above I get an array with 4 elements and not 3 when the delimiter
is
a comma.

My next stop is the Jet OLEDB provider, which expects CSV by default and
which I understand will handle other delimiters with a Schema.ini file.
Seems easy enough...

QUESTION:
Is there a better way than Jet or some .Net class that I am overlooking?

--
kevin...



Jun 17 '06 #6
Hi,
I meant using or adapting the code from opennetcf.org , I know it's not
trivial :)

I believe your selected path is not the best approach, just use one of the
already in existence solutions.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"kevin" <ke***@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...
This should be fairly trivial


Thats a bit of an overstatement, isn't it. I found a project on
CodeProject.com and that project is anything but trivial... not
overwhelming,
but involved.

http://www.thecodeproject.com/cs/dat...select=1499295

I actually decided to go with the regex solution. I'll first use split
and
if that returns and array with an incorrect size (I will know the number
of
fields), then I'll use the regex expression.

Thanks for the input
--
kevin...
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi Kevin,

Take a look at opennetcf.org they provide a CSV parser, has you will have
the code you can change (dont remember if this feature is present or not)
the code to instead of "," use any other character you want.

This should be fairly trivial
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
>I need to parse an third party supplied delimited or fixed width text
>file
> into a datatable. The delimiter may vary.
>
> I am currently using a SteamReader to read each line and, for delimited
> files, String.Split() to break each line into an array based on the
> delimiter. The problem, as you may guess, is that the delimiter
> character
> is
> being used in the data
>
> i.e. "Kevin","Williams,"I like commas, I really do"
>
> In the above I get an array with 4 elements and not 3 when the
> delimiter
> is
> a comma.
>
> My next stop is the Jet OLEDB provider, which expects CSV by default
> and
> which I understand will handle other delimiters with a Schema.ini file.
> Seems easy enough...
>
> QUESTION:
> Is there a better way than Jet or some .Net class that I am
> overlooking?
>
> --
> kevin...


Jun 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
6
by: ArunPrakash | last post by:
Hi, I have a web application that looks for a particular string in a set of huge files( the files grow into MBs - max i have seen is 30 MB ). ( search using reg expressions ). the string can occur...
7
by: Chris | last post by:
Hi I can use a text file as a datasource but am unable to get the datatable to see the text file as having multiple columns. Everything gets put into the first column in the datatable. Sample of...
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
22
by: JJ | last post by:
Whats the best way for me to pull out records from a tab delimited text file? Or rather HOW do I parse the text, knowing that the tabs are field delimiters and a return (I image) signifies a new...
13
by: JJ | last post by:
I have a need to input a large tab delimited text file, which I will parse to check it has the expected columns, before allowing the user to submit it to the database. The user may paste the file...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.