My ultimate goal is to open a text file database (.txt or .csv)either tab delimted or comma and count the records. Once that is done I can proceed with what I need to do with the data.
I’m doing ok but am kind of stuck right now.
- Open a text file (done)
- Read it’s contents (done)
- Determine the delimeter (not done)
- Count the records in the file (not done because of delimeter)
I’m using TextStream and what happening is the .Line command seems to be counting the tab delimeters as records :cantlook:
A solution I though of was to search for the delimeter and replace it with a different character, but this may lead to more issues further down the road with the application.
So I’m basically looking for someone to shed some light and toss me some advice on how they would go about doing this. Any links would be great - I can’t seems to find anything usefull on google or my favorite resource sites.
Here’s the current code I am working with
<%
set fsObj = Server.CreateObject("Scripting.FileSystemObject")
file_extension = (fsObj.GetExtensionName(file_name))
if (fsObj.FileExists(file_path & file_name)) = true Then
Response.Write "File: " & file_name & " exists" & "<br>"
Response.Write "The file extension is ." & file_extension & "<br><br>"
Set file_contents = fsObj.OpenTextFile(Server.MapPath(file_name),1)
Response.Write "File Contents: " & "<br>"
Response.Write "Headers are: " & "<br>"
Response.Write "<b>" & (file_contents.ReadLine) & "</b><br><br>"
Response.Write(file_contents.ReadAll) & "<br><br>"
Response.Write "There are " & file_contents.Line & " records " & file_name
file_contents.close
Else
Response.Write "File: " & file_name & " does not exist"
End if
set fsObj = Nothing
%>
Thanks :kommie: