| Author |
Topic Search Topic Options
|
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
Posted: 05 June 2004 at 5:02am |
|
Howcome you arn't using XML for this? It will be quite hard to do what you are trying to do and most likely pointless if you could do it with XML
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 05 June 2004 at 12:59pm |
|
I can't use xml. The text file is exported by an Access application,
and I have to deal with it. Also, the best way to something is the way
you know it. I never use xml, so I never though of it as a possible
solution.
|
|
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 06 June 2004 at 5:00pm |
|
Ok, i have tryed to put the rows in an array, then use the
Split(Rowarray(i), "[section]") to get the rows in a section, then put
them in an array to get the fields, nut with no luck. Any hints?
|
|
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 June 2004 at 10:03am |
Well, it seems there is no need for arrays... I have sorted it partially. I have put there only the response.write to simplify.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="connect.asp"-->
<%
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set theTextFile = FSO.OpenTextFile("E:\webs\ranbaxyromania.ro\wwwroot\files\tb lViziteDoctori1.txt")
While Not theTextFile.AtEndOfStream
theTextLine=theTextFile.ReadLine
If theTextline = "[section 1]" then
do
theTextLine=theTextFile.ReadLine
response.Write theTextLine & "<br>"
loop Until theTextLine = "[section 2]"
End if
If theTextline = "[section 2]" then
do
theTextLine=theTextFile.ReadLine
response.write theTextLine & "<br>"
loop Until theTextLine = "[section 3]"
End if
Wend
' Close up to be tidy
theTextFile.Close
Set theTextFile = Nothing
MyConn.Close
Set MyConn = Nothing
%>
|
The problem is that it lists also the section delimeter, and this crushes the insert. How can I skip this line?
|
|
|
 |
dpyers
Senior Member
Joined: 12 May 2003
Status: Offline
Points: 3937
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 June 2004 at 1:28pm |
If you're referring to the End-Of-Section delimiter, try changing the loop until the end of the section rather than the beginning of the new section - e.g.
Change Loop Until theTextLine = "[section 2]" To Loop Until theTextLine = "[/section 1]"
|
Lead me not into temptation... I know the short cut, follow me.
|
 |
zaboss
Senior Member
Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 June 2004 at 1:33pm |
Sorted out.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set theTextFile = FSO.OpenTextFile("E:\webs\ranbaxyromania.ro\wwwroot\files\tb lViziteDoctori1.txt")
While Not theTextFile.AtEndOfStream
theTextLine=theTextFile.ReadLine
If theTextline = "[section 1]" then
do
theTextLine=theTextFile.ReadLine
' Only Write it out if it isn't a section line
If theTextLine<>"[section 2]" Then
response.Write theTextLine & "<br>"
End If
loop Until theTextLine = "[section 2]"
End if
If theTextline = "[section 2]" then
do
theTextLine=theTextFile.ReadLine
' Only Write it out if it isn't a section line
If theTextLine<>"[section 3]" Then
response.write theTextLine & "<br>"
End IF
loop Until theTextLine = "[section 3]"
End if
Wend
' Close up to be tidy
theTextFile.Close
Set theTextFile = Nothing
%>
|
The problem was that, instead of If theTextLine<>"[section 2]", i
was putting If theTextLine="[section 2]", which, of course, gave me an
error...
|
|
|
 |
snapey
Newbie
Joined: 28 July 2002
Location: United Kingdom
Status: Offline
Points: 33
|
Post Options
Thanks(0)
Quote Reply
Posted: 18 June 2004 at 3:45pm |
Mart wrote:
Howcome you arn't using XML for this? It will be quite hard to do what you are trying to do and most likely pointless if you could do it with XML |
I want to do similar, but using XML. Can anyone point me in the direction of any examples of reading an XML file into an array or database in classic ASP?
|
 |