案例帮助 [英] CASE help

查看:55
本文介绍了案例帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在扫描HTML文件。

我需要从以< SMALL>开头的区域收集某些数据。文本。


让我展示代码,然后解释更多。

----

设置fso = CreateObject(& ; Scripting.FileSystemObject")

设置f = fso.GetFile(TheFilePath)


设置ts = f.OpenAsTextStream(1,-2)


Section =" Header"

Do while not ts.AtEndOfStream

Tmp_Line = ts.ReadLine

选择Case mid(Tmp_Line,48,2)

Case"

Section =" TheMoney"

Case" Pi"

案例"> J"

Section =" TheDate"

结束选择


选择案例部分

CaseTheMoney

TheMoney = TheMoney& FixGrades(Tmp_Line)& CHR(13)

案例ThePick

ThePick = ThePick& FixGrades(Tmp_Line)& CHR(13)

案例TheDate

TheDate = TheDate& FixGrades(Tmp_Line)& CHR(13)

结束选择


TextStreamTest = TextStreamTest& CHR(13)& FixGrades(Tmp_Line)

response.write TheMoney& "< BR>"

response.write ThePick& "< BR>"

response.write TheDate& "< BR>"


循环

ts.Close

---------- -


我的最终结果是能够获取TheMoney,ThePick,TheDate,然后将它们插入一个sql db中。然后扫描更多的html来查找

信息的下一个实例并插入到数据库中。我可以做所有db的东西。数据是

只是没有正确拉动。它会扫描每一行,而不仅仅是以HTML代码< SMALL>开头的

部分。我怎么能这样做

这个?然后,你看到我的最终结果我做错了吗?


我想用我的response.write图像看到文本显示为:

TheMoney

ThePick

TheDate

然后扫描html并找到另一个实例

TheMoney

ThePick

TheDate

等.....

I am scanning an HTML file.
I need to gather certain data from areas that start with <SMALL> text.

Let me show the code, then explain more.
----
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(TheFilePath)

Set ts = f.OpenAsTextStream(1,-2)

Section = "Header"
Do While not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
Case " "
Section = "TheMoney"
Case "Pi"
Section = "ThePick"
Case ">J"
Section = "TheDate"
End Select

Select Case Section
Case "TheMoney"
TheMoney = TheMoney & FixGrades(Tmp_Line) & CHR(13)
Case "ThePick"
ThePick = ThePick & FixGrades(Tmp_Line) & CHR(13)
Case "TheDate"
TheDate = TheDate & FixGrades(Tmp_Line) & CHR(13)
End Select

TextStreamTest = TextStreamTest & CHR(13) & FixGrades(Tmp_Line)
response.write TheMoney & "<BR>"
response.write ThePick & "<BR>"
response.write TheDate & "<BR>"

Loop
ts.Close
-----------

My end result is to be able to grab TheMoney,ThePick,TheDate and then insert
them into a sql db. Then to scan more html to find the next instance of the
information and insert into database. I can do all the db stuff. The data is
just not pulling correctly. And it scans EVERY LINE instead of only the
sections that start with the HTML code <SMALL>. How would I get it to do
this? Then, do you see anything else I am doing wrong for my end result?

I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....

推荐答案

你们知道所有行都至少有49个字符吗?

你可以这样做:

Do while not ts.AtEndOfStream

sPart = Mid(ts.ReadLine& String(49,"),48,2)

Select Case sPart

Case"

TheMoney = TheMoney& FixGrades(sPart)& CHR(13)

案例Pi

ThePick = ThePick& FixGrades(sPart)& CHR(13)

Case"> J"

TheDate = TheDate& FixGrades(sPart)& CHR(13)

结束选择


我并没有完全遵循你的目标,所以我想我只是修剪

稍微降低你的代码。 :]


雷在工作


Joey Martin <乔** @ infosmiths.net>在消息中写道

新闻:Uz **************** @ bignews1.bellsouth.net ...
Do you know for a fact that all lines will be at least 49 characters long?
You could do something like this:
Do While not ts.AtEndOfStream
sPart = Mid(ts.ReadLine & String(49," "), 48, 2)
Select Case sPart
Case " "
TheMoney = TheMoney & FixGrades(sPart) & CHR(13)
Case "Pi"
ThePick = ThePick & FixGrades(sPart) & CHR(13)
Case ">J"
TheDate = TheDate & FixGrades(sPart) & CHR(13)
End Select

I didn''t really follow exactly what your goal is, so I figured I''d just trim
down your code a little. :]

Ray at work

"Joey Martin" <jo**@infosmiths.net> wrote in message
news:Uz****************@bignews1.bellsouth.net...
我正在扫描一个HTML文件。
我需要从以< SMALL>开头的区域收集某些数据。文本。

让我展示代码,然后解释更多。
----
设置fso = CreateObject(" Scripting.FileSystemObject")
设置f = fso.GetFile(TheFilePath)

设置ts = f.OpenAsTextStream(1,-2)

Section =" Header"
Do while not ts。 AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
案例" "
Section =" TheMoney"
Case" Pi"
Section =" ThePick"
Case"> J"
Section =" TheDate
End Select

Select Case Section
CaseTheMoney
TheMoney = TheMoney& FixGrades(Tmp_Line)& CHR(13)
案例ThePick
ThePick = ThePick& FixGrades(Tmp_Line)& CHR(13)
案例TheDate
TheDate = TheDate& FixGrades(Tmp_Line)& CHR(13)
结束选择

TextStreamTest = TextStreamTest& CHR(13)& FixGrades(Tmp_Line)
response.write TheMoney& "< BR>"
response.write ThePick& "< BR>"
response.write TheDate& "< BR>"

循环
ts.Close
-----------

我的最终结果是能够获取TheMoney,ThePick,TheDate然后
将它们插入到sql db中。然后扫描更多的html以查找
的下一个实例信息并插入到数据库中。我可以做所有db的东西。数据
没有正确拉动。它会扫描每一行,而不仅仅是以HTML代码< SMALL>开头的
部分。我怎么能这样做呢
这个?然后,你看到我为我的最终结果做错了什么吗?

我会用我的response.write图像看到文字显示为:
TheMoney
ThePick
TheDate
然后扫描html并找到另一个实例
TheMoney
ThePick
TheDate
等......
I am scanning an HTML file.
I need to gather certain data from areas that start with <SMALL> text.

Let me show the code, then explain more.
----
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(TheFilePath)

Set ts = f.OpenAsTextStream(1,-2)

Section = "Header"
Do While not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
Case " "
Section = "TheMoney"
Case "Pi"
Section = "ThePick"
Case ">J"
Section = "TheDate"
End Select

Select Case Section
Case "TheMoney"
TheMoney = TheMoney & FixGrades(Tmp_Line) & CHR(13)
Case "ThePick"
ThePick = ThePick & FixGrades(Tmp_Line) & CHR(13)
Case "TheDate"
TheDate = TheDate & FixGrades(Tmp_Line) & CHR(13)
End Select

TextStreamTest = TextStreamTest & CHR(13) & FixGrades(Tmp_Line)
response.write TheMoney & "<BR>"
response.write ThePick & "<BR>"
response.write TheDate & "<BR>"

Loop
ts.Close
-----------

My end result is to be able to grab TheMoney,ThePick,TheDate and then insert them into a sql db. Then to scan more html to find the next instance of the information and insert into database. I can do all the db stuff. The data is just not pulling correctly. And it scans EVERY LINE instead of only the
sections that start with the HTML code <SMALL>. How would I get it to do
this? Then, do you see anything else I am doing wrong for my end result?

I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....



> Do while not ts.AtEndOfStream
> Do While not ts.AtEndOfStream
sPart = Mid(ts.ReadLine& String(49,""),48,2)


否雷,但每当我看到这种技术时,我总是试图纠正

吧。我认为以下会更有效率(至少某个文件

大小阈值),因为你没有处理整个文件

你的编码逻辑。


s = ts.ReadAll()

ts.close:set ts = nothing

s = split(s ,VBCrLf)

for i = 0 to ubound(s)

sPart = Mid(s(i)& String(49,""),48, 2)

...

next

将提高效率的上限,如调用

50 MB文件上的readall()不太可能。但我认为在大多数情况下,上述是一种比AtEndOfStream更好的技术。


-
http://www.aspfaq.com/

(反向回复地址。)



" Ray at<%= sLocation%> [MVP] QUOT; < myfirstname at lane34 dot com>写在

消息新闻:#D ************** @ TK2MSFTNGP10.phx.gbl ...你知道所有线路都在至少49个字符?
你可以这样做:

Do while not ts.AtEndOfStream
sPart = Mid(ts.ReadLine& String(49,"" ;),48,2)
选择Case sPart
案例"
TheMoney = TheMoney& FixGrades(sPart)& CHR(13)
案例Pi
ThePick = ThePick& FixGrades(sPart)& CHR(13)
案例"> J"
TheDate = TheDate& FixGrades(sPart)& CHR(13)
结束选择

我并没有完全遵循你的目标,所以我想我只需要
减少你的代码。 :]

Ray在工作中

Joey Martin <乔** @ infosmiths.net>在消息中写道
新闻:Uz **************** @ bignews1.bellsouth.net ...
sPart = Mid(ts.ReadLine & String(49," "), 48, 2)
No offense Ray, but whenever I see this technique, I always try to correct
it. I think the following will be much more efficient (to a certain file
size threshold, at least), since you''re not keeping a handle on the file
throughout your coding logic.

s = ts.ReadAll()
ts.close: set ts = nothing
s = split(s, VBCrLf)
for i = 0 to ubound(s)
sPart = Mid(s(i) & String(49, " "), 48, 2)
...
next
There will be an upper bound to the improved efficiency, as calling
readall() on a 50 MB file is not likely to be pretty. But I think in most
cases the above is a better technique than While not AtEndOfStream.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#D**************@TK2MSFTNGP10.phx.gbl... Do you know for a fact that all lines will be at least 49 characters long?
You could do something like this:
Do While not ts.AtEndOfStream
sPart = Mid(ts.ReadLine & String(49," "), 48, 2)
Select Case sPart
Case " "
TheMoney = TheMoney & FixGrades(sPart) & CHR(13)
Case "Pi"
ThePick = ThePick & FixGrades(sPart) & CHR(13)
Case ">J"
TheDate = TheDate & FixGrades(sPart) & CHR(13)
End Select

I didn''t really follow exactly what your goal is, so I figured I''d just trim down your code a little. :]

Ray at work

"Joey Martin" <jo**@infosmiths.net> wrote in message
news:Uz****************@bignews1.bellsouth.net...
我正在扫描一个HTML文件。
我需要从以< SMALL>开头的区域收集某些数据。文本。

让我展示代码,然后解释更多。
----
设置fso = CreateObject(" Scripting.FileSystemObject")
设置f = fso.GetFile(TheFilePath)

设置ts = f.OpenAsTextStream(1,-2)

Section =" Header"
Do while not ts。 AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
案例" "
Section =" TheMoney"
Case" Pi"
Section =" ThePick"
Case"> J"
Section =" TheDate
End Select

Select Case Section
CaseTheMoney
TheMoney = TheMoney& FixGrades(Tmp_Line)& CHR(13)
案例ThePick
ThePick = ThePick& FixGrades(Tmp_Line)& CHR(13)
案例TheDate
TheDate = TheDate& FixGrades(Tmp_Line)& CHR(13)
结束选择

TextStreamTest = TextStreamTest& CHR(13)& FixGrades(Tmp_Line)
response.write TheMoney& "< BR>"
response.write ThePick& "< BR>"
response.write TheDate& "< BR>"

循环
ts.Close
-----------

我的最终结果是能够抓住TheMoney,ThePick,TheDate,然后将
I am scanning an HTML file.
I need to gather certain data from areas that start with <SMALL> text.

Let me show the code, then explain more.
----
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(TheFilePath)

Set ts = f.OpenAsTextStream(1,-2)

Section = "Header"
Do While not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
Case " "
Section = "TheMoney"
Case "Pi"
Section = "ThePick"
Case ">J"
Section = "TheDate"
End Select

Select Case Section
Case "TheMoney"
TheMoney = TheMoney & FixGrades(Tmp_Line) & CHR(13)
Case "ThePick"
ThePick = ThePick & FixGrades(Tmp_Line) & CHR(13)
Case "TheDate"
TheDate = TheDate & FixGrades(Tmp_Line) & CHR(13)
End Select

TextStreamTest = TextStreamTest & CHR(13) & FixGrades(Tmp_Line)
response.write TheMoney & "<BR>"
response.write ThePick & "<BR>"
response.write TheDate & "<BR>"

Loop
ts.Close
-----------

My end result is to be able to grab TheMoney,ThePick,TheDate and then insert
插入到sql db中。然后扫描更多html以找到
them into a sql db. Then to scan more html to find the next instance of

信息的下一个实例并插入到数据库中。我可以做所有db的东西。
information and insert into database. I can do all the db stuff. The



数据是


data is

只是没有正确拉动。它会扫描每一行,而不仅仅是以HTML代码< SMALL>开头的
部分。我怎么能这样做呢
这个?然后,你看到我为我的最终结果做错了什么吗?

我会用我的response.write图像看到文字显示为:
TheMoney
ThePick
TheDate
然后扫描html并找到另一个实例
TheMoney
ThePick
TheDate
等......
just not pulling correctly. And it scans EVERY LINE instead of only the
sections that start with the HTML code <SMALL>. How would I get it to do
this? Then, do you see anything else I am doing wrong for my end result?

I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....




Ray和Aaron,

感谢您的投入......但它仍然无法帮助我我的最终结果。

我只想让它开始查看以< SMALL>

" Aaron [SQL Server MVP]"开头的代码块。 < TE ***** @ dnartreb.noraa>在消息中写道

新闻:%2 *************** @ TK2MSFTNGP12.phx.gbl ...
Ray and Aaron,
Thanks for your input...but it still does not help me get to my end result.
I only want it to start looking at blocks of code that start with <SMALL>
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Do while not ts.AtEndOfStream
sPart = Mid(ts.ReadLine& String(49,""),48,2)
Do While not ts.AtEndOfStream
sPart = Mid(ts.ReadLine & String(49," "), 48, 2)



没有冒犯雷,但每当我看到这种技术,我总是试图纠正它。我认为以下内容将更加高效(至少对某个文件大小阈值而言),因为在整个编码逻辑中你没有对文件进行处理。

s = ts.ReadAll()
ts.close:set ts = nothing
s = split(s,VBCrLf)
for i = 0 to ubound(s)
sPart = Mid(s(i)& String(49,"),48,2)
...
$

将有一个上限提高效率,因为在50 MB文件上调用readall()不太可能。但我认为在大多数情况下,上述是一种比不是AtEndOfStream更好的技术。

-
http://www.aspfaq.com/
(反向回复地址。)


; Ray at<%= sLocation%> [MVP] QUOT; < myfirstname at lane34 dot com>在
消息新闻中写道:#D ************** @ TK2MSFTNGP10.phx.gbl ...



No offense Ray, but whenever I see this technique, I always try to correct
it. I think the following will be much more efficient (to a certain file
size threshold, at least), since you''re not keeping a handle on the file
throughout your coding logic.

s = ts.ReadAll()
ts.close: set ts = nothing
s = split(s, VBCrLf)
for i = 0 to ubound(s)
sPart = Mid(s(i) & String(49, " "), 48, 2)
...
next
There will be an upper bound to the improved efficiency, as calling
readall() on a 50 MB file is not likely to be pretty. But I think in most
cases the above is a better technique than While not AtEndOfStream.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#D**************@TK2MSFTNGP10.phx.gbl...

你知道所有事实吗?行将至少49个字符
长?你可以这样做:

Do while not ts.AtEndOfStream
sPart = Mid(ts.ReadLine& String(49,""),48,2)
Select Case sPart
案例"
TheMoney = TheMoney& FixGrades(sPart)& CHR(13)
案例Pi
ThePick = ThePick& FixGrades(sPart)& CHR(13)
案例"> J"
TheDate = TheDate& FixGrades(sPart)& CHR(13)
结束选择

我并没有完全遵循你的目标,所以我想我只是
Do you know for a fact that all lines will be at least 49 characters long? You could do something like this:
Do While not ts.AtEndOfStream
sPart = Mid(ts.ReadLine & String(49," "), 48, 2)
Select Case sPart
Case " "
TheMoney = TheMoney & FixGrades(sPart) & CHR(13)
Case "Pi"
ThePick = ThePick & FixGrades(sPart) & CHR(13)
Case ">J"
TheDate = TheDate & FixGrades(sPart) & CHR(13)
End Select

I didn''t really follow exactly what your goal is, so I figured I''d just


trim


trim

稍微降低你的代码。 :]

Ray在工作中

Joey Martin <乔** @ infosmiths.net>在消息中写道
新闻:Uz **************** @ bignews1.bellsouth.net ...
down your code a little. :]

Ray at work

"Joey Martin" <jo**@infosmiths.net> wrote in message
news:Uz****************@bignews1.bellsouth.net...
我正在扫描一个HTML文件。
我需要从以< SMALL>开头的区域收集某些数据。文本。

让我展示代码,然后解释更多。
----
设置fso = CreateObject(" Scripting.FileSystemObject")
设置f = fso.GetFile(TheFilePath)

设置ts = f.OpenAsTextStream(1,-2)

Section =" Header"
Do while not ts。 AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
案例" "
Section =" TheMoney"
Case" Pi"
Section =" ThePick"
Case"> J"
Section =" TheDate
End Select

Select Case Section
CaseTheMoney
TheMoney = TheMoney& FixGrades(Tmp_Line)& CHR(13)
案例ThePick
ThePick = ThePick& FixGrades(Tmp_Line)& CHR(13)
案例TheDate
TheDate = TheDate& FixGrades(Tmp_Line)& CHR(13)
结束选择

TextStreamTest = TextStreamTest& CHR(13)& FixGrades(Tmp_Line)
response.write TheMoney& "< BR>"
response.write ThePick& "< BR>"
response.write TheDate& "< BR>"

循环
ts.Close
-----------

我的最终结果是能够抓住TheMoney,ThePick,TheDate然后
I am scanning an HTML file.
I need to gather certain data from areas that start with <SMALL> text.

Let me show the code, then explain more.
----
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(TheFilePath)

Set ts = f.OpenAsTextStream(1,-2)

Section = "Header"
Do While not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
Case " "
Section = "TheMoney"
Case "Pi"
Section = "ThePick"
Case ">J"
Section = "TheDate"
End Select

Select Case Section
Case "TheMoney"
TheMoney = TheMoney & FixGrades(Tmp_Line) & CHR(13)
Case "ThePick"
ThePick = ThePick & FixGrades(Tmp_Line) & CHR(13)
Case "TheDate"
TheDate = TheDate & FixGrades(Tmp_Line) & CHR(13)
End Select

TextStreamTest = TextStreamTest & CHR(13) & FixGrades(Tmp_Line)
response.write TheMoney & "<BR>"
response.write ThePick & "<BR>"
response.write TheDate & "<BR>"

Loop
ts.Close
-----------

My end result is to be able to grab TheMoney,ThePick,TheDate and then


插入到sql db中。然后扫描更多html,找到下一个实例
them into a sql db. Then to scan more html to find the next instance of
信息并插入数据库。我可以做所有db的东西。
information and insert into database. I can do all the db stuff. The


数据

只是没有正确拉动。并且它扫描每一行而不是仅
just not pulling correctly. And it scans EVERY LINE instead of only



以HTML代码< SMALL>开头的部分。我怎么能得到
这样做?然后,你看到我的结果
结果我做错了什么?
我会用我的response.write图像看到文本显示为:
TheMoney
ThePick
TheDate
然后扫描html并找到另一个实例
TheMoney
ThePick
TheDate
等......


the sections that start with the HTML code <SMALL>. How would I get it to do this? Then, do you see anything else I am doing wrong for my end result?
I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....





这篇关于案例帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆