| |||
Lectura de Archivo *.txt Hola a Todos! Necesito de su ayuda. Abro un archivo .txt mediante el objeto FSO pero al momento de recorrer el archivo con el ReadLine y SkipLine me salta muchas líneas intermedias. En Resumen, de un total de 52 líneas solo leo 26. ¿Qué puedo hacer? Muchas Gracias |
| |||
Leer Archivo.txt Este es por completo el Script. Ojala puedas ayudarme... <% Dim FSO, oCarpeta, colFicheros, fichero, oFichero Dim sContenido Dim codCliete, numPedido, fechaHoraped, fechaHorapro, codPostal, ordenCompra Dim numEntrega, codProd, cantidad, contador set FSO = Server.CreateObject("Scripting.FileSystemObject") set oCarpeta = FSO.GetFolder("C:\") set colFicheros = oCarpeta.Files contador=1 %> <html> <head> <meta http-equiv="Content-Language" content="es-cl"> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Pagina nueva 1</title> </head> <body background="imagen/plomo.jpg"> <p> </p> <p> </p> <div align="left"> <table border="1" cellspacing="1" width="100%" id="AutoNumber1" align="left"> <tr> <td width="2%" bgcolor="#C0D9D9">#</td> <td width="4%" bgcolor="#C0D9D9">Pedido</td> <td width="7%" bgcolor="#C0D9D9">Entrega</td> <td width="7%" bgcolor="#C0D9D9">Orden Compra</td> <td width="5%" bgcolor="#C0D9D9">Fecha Pedido</td> <td width="5%" bgcolor="#C0D9D9">Fecha Prometida</td> <td width="5%" bgcolor="#C0D9D9">Cliente Solicita</td> <td width="5%" bgcolor="#C0D9D9">Cliente Entrega</td> <td width="6%" bgcolor="#C0D9D9">Dirección</td> <td width="6%" bgcolor="#C0D9D9">Ciudad</td> <td width="6%" bgcolor="#C0D9D9">Comuna</td> <td width="6%" bgcolor="#C0D9D9">Producto</td> <td width="6%" bgcolor="#C0D9D9">Modelo</td> <td width="6%" bgcolor="#C0D9D9">Cantidad</td> </tr> <% for each fichero in colFicheros if fichero.Name="pedidos.txt" then set oFichero = fichero.OpenAsTextStream(1) Do While oFichero.AtEndOfStream<>True sContenido="" sContenido = oFichero.ReadLine codCliente=Mid(sContenido,1,9) numPedido=Mid(sContenido,146,10) fechaHoraped=Mid(sContenido,225,15) fechaHorapro=Mid(sContenido,241,15) codPostal=Mid(sContenido,257,9) ordenCompra=Mid(sContenido,410,30) numEntrega=Mid(sContenido,472,30) codProd=Mid(sContenido,503,20) cantidad=Mid(sContenido,565,12) response.write(sContenido) %> <tr> <td width="2%" bgcolor="#C0D9D9"><%=contador%nbsp;</td> <td width="4%"><%=numpedido%> </td> <td width="7%"><%=numEntrega%> </td> <td width="7%"><%=ordenCompra%> </td> <td width="5%"><%=fechaHoraped%> </td> <td width="5%"><%=fechaHorapro%> </td> <td width="5%"><%=codCliente%> </td> <td width="5%"><%=codPostal%> </td> <td width="6%"> </td> <td width="6%"> </td> <td width="6%"> </td> <td width="6%"> </td> <td width="6%"><%=codProd%> </td> <td width="6%"><%=cantidad%> </td> </tr> <% oFichero.SkipLine contador=contador+1 Loop oFichero.Close set oFichero = nothing end if next %> </table> <br> </div> </body> </html> <% set colFicheros = nothing set oCarpeta = nothing set FSO = nothing %> Este es todo el Script |
| ||||
ok, te comento que (dejando de lado todo el HTML, las partes ASP que no influirían en tu script y luego de probarlo), Mickel tenía la razón! el problema está en el skipline Acá te dejo el script que use para probar (que no es más que una versión reducida del tuyo): <% Dim FSO, oCarpeta, colFicheros, fichero, oFichero Dim sContenido Dim codCliete, numPedido, fechaHoraped, fechaHorapro, codPostal, ordenCompra Dim numEntrega, codProd, cantidad, contador set FSO = Server.CreateObject("Scripting.FileSystemObject") set oCarpeta = FSO.GetFolder("C:\") set colFicheros = oCarpeta.Files 'contador=1 for each fichero in colFicheros if fichero.Name="pedidos.txt" then set oFichero = fichero.OpenAsTextStream(1) Do While oFichero.AtEndOfStream<>True sContenido="" sContenido = oFichero.ReadLine response.write(sContenido & "<br>") 'oFichero.SkipLine 'contador=contador+1 Loop oFichero.Close set oFichero = nothing end if next %> Fijate las cosas que "comenté" (y marqué en negritas) y que tal vez estén de más -como el contador-... El skipline SI está de más Tambien te dejo el archivo TXT que utilicé a manera de ejemplo, según tus especificaciones (ubicado en C: y con el mismo nombre que vos le diste, salvo que con otro contenido): Linea 1 Linea 2 Linea 3 Linea 4 Linea 5 Linea 6 Linea 7 Linea 8 Linea 9 Linea 10 Linea 11 Linea 12 Linea 13 Linea 14 Linea 15 Linea 16 Linea 17 Linea 18 Linea 19 Linea 20 Sin usar skipline, el resultado es la lectura de TODAS las lineas. Usándolo, sólo veo las impares. saludos Última edición por AlZuwaga; 10/04/2003 a las 23:13 |