|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Open a CSV fileHi,
I've exported our Exchange 5.5 server info into a CSV file. I know want to create a VB.Net application which reads the CSV file and then process the information in it. Can anyone tell me what I should do to create the application. The file is called info.csv. And I want to process it row by row. Kind Regards Stefke Hi Stefke,
dim SR as New StreamReader("c:\My Documents\info.csv") dim txtLine as String dim Strings as String() txtLine = SR.ReadLine() Strings()=String.Split(",",txtLine) Show quoteHide quote "Stefke" <sf***@tiscali.be> wrote in message news:OwequZPOFHA.3668@TK2MSFTNGP14.phx.gbl... > Hi, > > I've exported our Exchange 5.5 server info into a CSV file. I know want to > create a VB.Net application which reads the CSV file and then process the > information in it. > > Can anyone tell me what I should do to create the application. The file is > called info.csv. > And I want to process it row by row. > > Kind Regards > > Stefke > > It should be noted that whilst this would "normally" work, it will fail if
the data contacts a comma ... eg "hello","this has a comma, see!!",100 You would need to parse the string looking for opening and closing quotation marks and taking commas between them as part of the data and not a delimiter. Herfried and Cor's suggestion for using the text connection string would do this for you... Regards Simon Show quoteHide quote "Pipo" <P***@nobody.com> wrote in message news:eNy$yiPOFHA.2520@tk2msftngp13.phx.gbl... > Hi Stefke, > > dim SR as New StreamReader("c:\My Documents\info.csv") > dim txtLine as String > dim Strings as String() > txtLine = SR.ReadLine() > Strings()=String.Split(",",txtLine) > > > "Stefke" <sf***@tiscali.be> wrote in message > news:OwequZPOFHA.3668@TK2MSFTNGP14.phx.gbl... >> Hi, >> >> I've exported our Exchange 5.5 server info into a CSV file. I know want > to >> create a VB.Net application which reads the CSV file and then process the >> information in it. >> >> Can anyone tell me what I should do to create the application. The file > is >> called info.csv. >> And I want to process it row by row. >> >> Kind Regards >> >> Stefke >> >> > > "Stefke" <sf***@tiscali.be> schrieb: <URL:http://www.connectionstrings.com/>> I've exported our Exchange 5.5 server info into a CSV file. I know want > to > create a VB.Net application which reads the CSV file and then process the > information in it. > > Can anyone tell me what I should do to create the application. The file > is > called info.csv. > And I want to process it row by row. -> "Text" -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Stefke,
\\\ Private Sub Form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim file As String = "Test2.txt" Dim path As String = "C:\Test1\" Dim ds As New DataSet Try Dim f As System.IO.File If f.Exists(path & file) Then Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ path & ";Extended Properties=""Text;HDR=No;FMT=Delimited\""" Dim conn As New OleDb.OleDbConnection(ConStr) Dim da As New OleDb.OleDbDataAdapter("Select * from " & _ file, conn) da.Fill(ds, "TextFile") End If Catch ex As Exception MessageBox.Show(ex.ToString) End Try DataGrid1.DataSource = ds.Tables(0) End Sub /// I hope this helps a little bit? Cor The benchmarks of processing csv files using the microsoft drivers are
not very good. http://www.codeproject.com/cs/database/CsvReader.asp http://www.geocities.com/shriop/csv_benchmarks.html |
|||||||||||||||||||||||