Reading and Displaying a comma delimited text file to a table.

Reply

Join Date: Dec 2006
Posts: 7
Reputation: blakisa is an unknown quantity at this point 
Solved Threads: 0
blakisa blakisa is offline Offline
Newbie Poster

Reading and Displaying a comma delimited text file to a table.

 
0
  #1
Dec 11th, 2006
Hi All,

Anyone know of an efficient way to read a data text file in comma delimited format and displaying the information to a table. I read some of the previous post, but they did not seem too informative.

Basically,

Check file existance, display if not availible
Load variables from file
Diplay variables to table
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 5
Reputation: ammarcool is an unknown quantity at this point 
Solved Threads: 0
ammarcool ammarcool is offline Offline
Newbie Poster

Re: Reading and Displaying a comma delimited text file to a table.

 
0
  #2
Jan 26th, 2007
Originally Posted by blakisa View Post
Hi All,

Anyone know of an efficient way to read a data text file in comma delimited format and displaying the information to a table. I read some of the previous post, but they did not seem too informative.

Basically,

Check file existance, display if not availible
Load variables from file
Diplay variables to table
hii!

just try the following code: hope it might help you! i have used the Microsoft Text Driver to read the content from the CSV file strieghtly & populating a Grid with the fetched data!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dtRecords As DataTable
Dim dr As DataRow
dtRecords = GetDataTable("SELECT * FROM members2.csv")
DataGridView1.DataSource = dtRecords

End Sub

Private Function GetConnection()
Return "Driver={Microsoft Text Driver (*.txt; *.csv)};HDR=YES;Extensions=asc,csv,tab,txt;Dbq= " & Application.StartupPath & "\;"
End Function

Private Function GetDataTable(ByVal sql As String)
Dim rt As DataTable
Dim da As OdbcDataAdapter
Dim con As OdbcConnection
Dim cmd As OdbcCommand
Try
rt = New DataTable()
ds = New DataSet()
da = New OdbcDataAdapter()
con = New OdbcConnection(GetConnection())
cmd = New OdbcCommand(sql, con)
da.SelectCommand = cmd
da.Fill(ds)
rt = ds.Tables(0)
Label1.Text = "Records in the CSV:" + CStr(ds.Tables(0).Rows.Count)
Catch ex As Exception
rt = Nothing
MsgBox(ex.Message)
End Try
Return rt
End Function

regards,

Ammar.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 12
Reputation: jenny4u is an unknown quantity at this point 
Solved Threads: 0
jenny4u jenny4u is offline Offline
Newbie Poster

Re: Reading and Displaying a comma delimited text file to a table.

 
0
  #3
Feb 20th, 2007
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 107
Reputation: madmital is an unknown quantity at this point 
Solved Threads: 3
madmital madmital is offline Offline
Junior Poster

Re: Reading and Displaying a comma delimited text file to a table.

 
0
  #4
Feb 25th, 2007
This is an asp forum, ammarcool...not .NET.

  1. <%
  2. set fso = server.createobject("scripting.filesystemobject")
  3. set file = fso.opentextfile(server.mappath(".") & "/data.txt", 1)
  4. data = file.readall()
  5. file.close
  6. lines = split(data, VbCrLf)
  7.  
  8. response.write "<table border=1>"
  9.  
  10. for each line in lines
  11. subline = split(line, ",")
  12. response.write "<tr>"
  13. for each val in subline
  14. response.write "<td>" & val & "</td>"
  15. next
  16. response.write "</tr>"
  17. next
  18.  
  19. response.write "</table>"
  20.  
  21. set fso = nothing : set file = nothing
  22. %>
Web Developer
When something seems too good to be true...it usually is
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 3
Reputation: wim2440 is an unknown quantity at this point 
Solved Threads: 0
wim2440 wim2440 is offline Offline
Newbie Poster

Re: Reading and Displaying a comma delimited text file to a table.

 
0
  #5
Feb 25th, 2007
Originally Posted by blakisa View Post
Hi All,

Anyone know of an efficient way to read a data text file in comma delimited format and displaying the information to a table. I read some of the previous post, but they did not seem too informative.

Basically,

Check file existance, display if not availible
Load variables from file
Diplay variables to table
==>
hi,
i usually open the file in excel, manupulate the data as needed and then import the file into a table in autocad, using simple cut & paste.
best regards and succes
wim.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 3
Reputation: wim2440 is an unknown quantity at this point 
Solved Threads: 0
wim2440 wim2440 is offline Offline
Newbie Poster

Re: Reading and Displaying a comma delimited text file to a table.

 
0
  #6
Feb 25th, 2007
hi,
i usually open the file in excel, manupulate the data as needed and then import the file into a table in autocad, using simple cut & paste.
best regards and succes
wim.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC