Importing CVS files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm wondering if there's any quick way to extract data from a CSV file using C# or whether I'll need to write code to read lines from the file and break down the resulting strings. No need for code examples if I have to do the latter, cheers, just looking for some quick pointers in the right direction

Cat
 
Depending on what your end goal is, you can import it directly into a
dataset using the Oledb driver http://www.connectionstrings.com/ (check
under the section for 'text')
logicalfeline said:
I'm wondering if there's any quick way to extract data from a CSV file
using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.
 
Hi,

www.opennetcf.org there you will find an implementation

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

logicalfeline said:
I'm wondering if there's any quick way to extract data from a CSV file
using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.
 
As far as I know, there's no built-in way in the FrameWork itself.
Regex.Split is the one I use.

--
Alex Moskalyuk
_____________________________
http://www.techinterviews.com

logicalfeline said:
I'm wondering if there's any quick way to extract data from a CSV file
using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.
 
...
I'm wondering if there's any quick way to extract data from a CSV file
using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.

The following thread in news://microsoft.public.dotnet.framework.adonet has
some code available for it, as well as information on using SQL DTS
packages.

Subject: Importing CSV Files Into MSDE Databases
Date: Friday, March 19, 2004 6:46 PM
 
How would I go about doing that?

William Ryan eMVP said:
Depending on what your end goal is, you can import it directly into a
dataset using the Oledb driver http://www.connectionstrings.com/ (check
under the section for 'text')

using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.
 
Logical,

writing the code necessary to parse the CSV file is quite trivial in C#
(I've done it in C++ and PL/SQL as well). Here is alink to an article that
I wrote that shows one approach -- (look about half way down in the article
for the ScanLine method that implements the state machine for generating the
tokes for a line)...

http://www.onecustomer.com/TechArticles/TechArt15.html

regards
roy fine


logicalfeline said:
I'm wondering if there's any quick way to extract data from a CSV file
using C# or whether I'll need to write code to read lines from the file and
break down the resulting strings. No need for code examples if I have to do
the latter, cheers, just looking for some quick pointers in the right
direction.
 
you could also use the OPENROWSET function..

this SQL snippet will allow you to import the C:\Customers.csv file directly into your MSDE Databas

SELECT
INTO myImportTabl
FROM
OPENROWSET('MSDASQL'
'Driver={Microsoft Text Driver (*.txt; *.csv)};DEFAULTDIR=C:\;Extensions=CSV;'
'SELECT * FROM Customers.CSV'
 
Back
Top