•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 456,420 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,631 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 8479 | Replies: 5
![]() |
•
•
Join Date: Dec 2006
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Jan 2007
Location: Colombo
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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.
•
•
Join Date: Jun 2005
Location: Denmark, EU
Posts: 102
Reputation:
Rep Power: 4
Solved Threads: 3
This is an asp forum, ammarcool...not .NET.
<%
set fso = server.createobject("scripting.filesystemobject")
set file = fso.opentextfile(server.mappath(".") & "/data.txt", 1)
data = file.readall()
file.close
lines = split(data, VbCrLf)
response.write "<table border=1>"
for each line in lines
subline = split(line, ",")
response.write "<tr>"
for each val in subline
response.write "<td>" & val & "</td>"
next
response.write "</tr>"
next
response.write "</table>"
set fso = nothing : set file = nothing
%> Web Programmer
•
•
Join Date: Feb 2007
Location: belgium
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- how can we sort data from text file (C++)
- C++ Reading from a text file (C++)
- REgistering new members as groups in ipb (Growing an Online Community)
- PHP newbie, project feasibility (PHP)
Other Threads in the ASP Forum
- Previous Thread: Checkbox input to an Access DB via ASP and JScript
- Next Thread: string tokenizer


Linear Mode