Print Page | Close Window

Work with text file

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=23
Printed Date: 28 March 2026 at 10:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Work with text file
Posted By: michael
Subject: Work with text file
Date Posted: 10 February 2003 at 4:07pm

I have an application that can only export to a comma delimited text file. The application does not let me format what data is incuded basically spits out the whole table. I cannot query the table directly because first it's not in the same network then the webserver and it's BTrieve

Now my question, I created a file which takes that text file, formats it a little and displays it within an intranet. Now there are three columns that I don't want to display ( the first, third and fourth) where the whole text file has like 10 columns. Anyone got an idea how?? No ideas how to query a text file and the person who is gonna do the exports will not go through the process of importing them to a database.
Here is what I have so far:

<%
' This script only works with the interchange export from OPS
fontsize = "-5"      'please specify the desired font size here  -6 , -5 , .... , +5 , +6
fontface = "Times New Roman"  'please specify the desired font face here  (Arial or whatever you prefer.)
whichfile=server.mappath("/export.txt") 'change the filename of the txt file here, have it in the same dir as this asp file

Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 1, False,TristateFalse)

counter=0
do  while not thisfile.AtEndOfStream
  
   thisline=thisfile.readline
   tableline = "<tr><td nowrap><font size=" & fontsize & " face=" & fontface & ">" & Replace(thisline,",","</td><td nowrap><font size=" & fontsize & " face=" & fontface & ">") & "</td></tr>"
   tableline = Replace(tableline,"""","")
   Response.Write tableline
loop

thisfile.Close
set thisfile=nothing
set fs=nothing
%>



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Replies:
Posted By: Str8Dog
Date Posted: 10 February 2003 at 4:45pm
you could set up the CSV as a linked table inside an access DB. This would allow you to query it.

-------------
http://www.str8dog.com/ - [IMG - http://www.str8dog.com/images/str8dog.gif -
I wasn't born with enough middle fingers.


Posted By: michael
Date Posted: 10 February 2003 at 5:38pm
This is actually not a bad idea. Though would I need to setup a DSN for the CSV or does it go without.


Posted By: Bunce
Date Posted: 11 February 2003 at 5:25pm

I think you can connect to a text file as if it were a recordset, you can then manipulate which rows you wish to display.

http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderFormicrosoftJetText - http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForMicrosoftJetText

http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForText - http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForText

Hope this helps,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: michael
Date Posted: 11 February 2003 at 5:43pm
Thanks Bunce, actually converting it to a csv did the whole trick. Sometimes it is so close you don't see it :)


Posted By: gupta_ji
Date Posted: 30 October 2003 at 9:02am
you could set up the CSV as a linked table inside an access DB. This would allow you to query it.


-------------
http://www.sgrj.com" rel="nofollow - chartered accountants India , http://www.delhiprofessionals.com" rel="nofollow - accounting Outsourcing ISO Certification



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net