关于读取TXT文件的问题。

zjx1302 2010-06-29 09:40:50
我的文本文件的内容如下:
cata4 cata5 cata6 name sn Descriptions pic1 pic2 stocknum jg l Operator
jersey NFL jersey Tampa Bay Buccaneers Tampa Bay Buccaneers TAMPA BAY BUCCANEERS NFL-029 """<DIV align=center>
<TABLE cellPadding=0 width=""""93%"""" align=center border=1>
<TBODY>
<TR>
<TD width=""""99%"""">
<DIV align=center><FONT face=""""Times New Roman"""" color=#11ee3d size=3><STRONG>If you cannot get the players that displayed on our web, you can contact our online service or email us to get newest stock list, Also we can help you to produce jerseys that you want to satisfy you. Thanks.</STRONG></FONT></DIV></TD></TR></TBODY></TABLE></DIV>""" 20100522021112220-s.jpg 20100522021112220-s.jpg 180 0 8 1
jersey NFL jersey Tampa Bay Buccaneers Tampa Bay Buccaneers TAMPA BAY BUCCANEERS NFL-030 """<DIV align=center>
<TABLE cellPadding=0 width=""""93%"""" align=center border=1>
<TBODY>
<TR>
<TD width=""""99%"""">
<DIV align=center><FONT face=""""Times New Roman"""" color=#11ee3d size=3><STRONG>If you cannot get the players that displayed on our web, you can contact our online service or email us to get newest stock list, Also we can help you to produce jerseys that you want to satisfy you. Thanks.</STRONG></FONT></DIV></TD></TR></TBODY></TABLE></DIV>""" 20100522021112220-s.jpg 20100522021112220-s.jpg 180 0 8 1
jersey NFL jersey Tampa Bay Buccaneers Tampa Bay Buccaneers TAMPA BAY BUCCANEERS NFL-031 """<DIV align=center>
<TABLE cellPadding=0 width=""""93%"""" align=center border=1>
<TBODY>
<TR>
<TD width=""""99%"""">
<DIV align=center><FONT face=""""Times New Roman"""" color=#11ee3d size=3><STRONG>If you cannot get the players that displayed on our web, you can contact our online service or email us to get newest stock list, Also we can help you to produce jerseys that you want to satisfy you. Thanks.</STRONG></FONT></DIV></TD></TR></TBODY></TABLE></DIV>""" 20100522021112220-s.jpg 20100522021112220-s.jpg 180 0 8 1


上面这些数据库从EXCEL导成制表符TXT文件,一共有三条记录我现在将这个数据读取出来然后把对应的字段写入ACCESS中。
代码如下:


set MyFileObject=server.CreateObject("Scripting.FileSystemObject")
set MyLogFile=MyFileObject.OpenTextFile(server.MapPath(a&filenameback&"."&filekzmzz),1)
response.write a&filenameback&"."&filekzmzz
k=0
while not MyLogFile.AtEndOfStream
if k=0 then '去掉第一行,第一行是标题
LogMessage=Trim(MyLogFile.readline)
response.write "<br>" & logMessage & "<br>"
k=k+1
end if
LogMessage=Trim(MyLogFile.readline)
response.write "<br>" & logMessage & "<br>"

if LogMessage<>"" then
LogArr = split(LogMessage,vbTab)
response.write "<br>5:" & Trim(LogArr(5)) & "<br>4:" &Trim(LogArr(4)) & "<br>3:" &Trim(LogArr(3)) & "<br>2:" &Trim(LogArr(2)) & "<br>1:"&Trim(LogArr(1)) & "<br>0:"&Trim(LogArr(0))
response.end
end if
wend

读取出来后我将显示第一行结果如下:
jersey NFL jersey Tampa Bay Buccaneers Tampa Bay Buccaneers TAMPA BAY BUCCANEERS NFL-029 """
从上面这个可以看出来读到"<"时就认为是换行回车了,可实际上又不是,请高手们帮我看看,如何解决这个问题。
...全文
118 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjx1302 2010-06-29
  • 打赏
  • 举报
回复
我刚才试了下,发现如你所说的那样。

发现里面回车所以才会这样。我在改一下就知道问题出现在哪里了。结贴给分。谢谢....
  • 打赏
  • 举报
回复
set MyFileObject=server.CreateObject("Scripting.FileSystemObject") 
set MyLogFile=MyFileObject.OpenTextFile(server.MapPath(a&filenameback&"."&filekzmzz),1)
k=0
while not MyLogFile.AtEndOfStream
if k=0 then '去掉第一行,第一行是标题
LogMessage=Trim(MyLogFile.readline)
k=k+1
else
LogMessage=Trim(MyLogFile.readline)
if LogMessage<>"" then
LogArr = split(LogMessage,vbTab)
response.write LogMessage
'response.write "<br>5:" & Trim(LogArr(5)) & "<br>4:" &Trim(LogArr(4)) & "<br>3:" &Trim(LogArr(3)) & "<br>2:" &Trim(LogArr(2)) & "<br>1:"&Trim(LogArr(1)) & "<br>0:"&Trim(LogArr(0))
'response.end
end if
end if
wend

你改成这样看就知道了
  • 打赏
  • 举报
回复
我觉得你自己理解错误了

实际上你上面的代码可以读取到
jersey NFL jersey Tampa Bay Buccaneers Tampa Bay Buccaneers TAMPA BAY BUCCANEERS NFL-029 """<DIV align=center>
这里就断了,然后输出了<br>然而,你浏览器浏览是看不到<DIV align=center>的
你查看源代码就知道了

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧