JavaScript - trabajar con datos de un txt

 
Vista:
sin imagen de perfil

trabajar con datos de un txt

Publicado por esteban (1 intervención) el 21/04/2016 21:48:07
Estoy un poco perdido, en su momento, años ah. Con visual cree unos formularios. Estoy intentando realizarlo en html.
tengo unos archivos de texto como datos creado por un programa.
c:\MAPPERS Archivo PV (.PV).
c:\PVS Archivo PV (.PV).
ej.

IB 081930200905300250MAD 1321ECJQZ T07 00A200905300254AKLF continua..
V7 94229200905300315MAD 1321ECILP P24 00A200905300323AKLI continua..
RGN 901130200905300650TFN 1D8CECIGZ T13 A200905300727A continua..
y x datos por linea.

Necesito que cuando carge la pagina me lea un archivo c:\MAPPERS Archivo PV (.PV). y si elijo otra fecha lea un archivo c:\PVS Archivo PV (.PV).

Lo que tengo de momento en notepad++

<body>
<div class="contenedor">
<div class="cabecera">
<img src="http://static.corp.iberia.es/atlas/img/logo_134x29.png" alt="Iberia">
<script>
$(function () {
$.datepicker.setDefaults($.datepicker.regional["es"]);
$("#datepicker").datepicker({
dateFormat: 'dd/mm/yy',
firstDay: 1
}).datepicker("setDate", new Date());
});
</script>
<h1>Webreport Airport Service </h1>v.1.0
<BR>
<BR>
Selecciona Fecha:&nbsp;&nbsp;
<input type="text" id="datepicker"/>
<BR>

<ul>
<li>

<input type="radio" name="group1" value="Vuelos de Llegada">Vuelos de Llegada<br>

</li>
<li>
<input type="radio" name="group1" value="Vuelos de salida" checked>Vuelos de salida<br>
</li>

</ul>
<br>

</div>
<P>Hora UTC</p>
<div class="barra">


<script type="text/javascript"> function startTime(){ today=new Date(); h=today.getUTCHours(); m=today.getMinutes(); s=today.getSeconds(); m=checkTime(m); s=checkTime(s); document.getElementById('reloj').innerHTML=h+":"+m+":"+s; t=setTimeout('startTime()',500);} function checkTime(i) {if (i<10) {i="0" + i;}return i;} window.onload=function(){startTime();} </script> <div id="reloj"></div>





</div>
<div class="marco">
<div class="contenido">

<br>
<table id='miTabla' class='TablaOrden'>
<caption>Datos Vuelos..</caption>
<thead>
<th onclick="TablaOrden.en('miTabla',0)">CIA</th>
<th>VUELO</th>
<th>DT1</th>
<th>DT2</th>
<th onclick="TablaOrden.en('miTabla',4)">STD</th>
<th onclick="TablaOrden.en('miTabla',5)">ETD</th>
<th>Coord</th>
</thead>
<tbody>
<TR><TD>VY</TD><TD>3001</TD><TD>BCN</TD><TD>TXL</TD><TD>1325</TD><TD>1400</TD><TD>alco</TD><TD><a href="http://microsoft.com" style="color:red" >F.C&nbsp;&nbsp;&nbsp;</a></TD><TD><a href="http://microsoft.com" style="color:blue" >F.P&nbsp;&nbsp;&nbsp;</TD><TD><a href="http://microsoft.com" style="color:YELLOW" >F.U&nbsp;&nbsp;&nbsp;</TD></TR>
<TR><TD>RGN</TD><TD>9011</TD><TD>MAD</TD><TD>BCN</TD><TD>0900</TD><TD>0900</TD><TD>speL</TD><TD><a href="http://microsoft.com" style="color:red" >F.C&nbsp;&nbsp;&nbsp;</a></TD><TD><a href="http://microsoft.com" style="color:blue" >F.P&nbsp;&nbsp;&nbsp;</TD><TD><a href="http://microsoft.com" style="color:YELLOW" >F.U&nbsp;&nbsp;&nbsp;</TD></TR>
<TR ><TD>DE</TD><TD>1052</TD><TD>HAJ</TD><TD>DUS</TD><TD>1200</TD><TD>1158</TD><TD>anaL</TD><TD><a href="http://microsoft.com" style="color:red" >F.C&nbsp;&nbsp;&nbsp;</a></TD><TD><a href="http://microsoft.com" style="color:blue" >F.P&nbsp;&nbsp;&nbsp;</TD><TD><a href="http://microsoft.com" style="color:YELLOW" >F.U&nbsp;&nbsp;&nbsp;</TD></TR>
<TR><TD>MT</TD><TD>1406</TD><TD>LGW</TD><TD>MAN</TD><TD>1500</TD><TD>1505</TD><TD>ctul</TD><TD><a href="http://microsoft.com" style="color:red" >F.C&nbsp;&nbsp;&nbsp;</a></TD><TD><a href="http://microsoft.com" style="color:blue" >F.P&nbsp;&nbsp;&nbsp;</TD><TD><a href="http://microsoft.com" style="color:YELLOW" >F.U&nbsp;&nbsp;&nbsp;</TD></TR>

</tbody>
</table>

me gustaría dependiendo del <input type="text" id="datepicker"/>

me busque en cada linea el valor fecha en formato ddyyyymm.En la fila lee desde el carácter 9 y son 8 caracteres.

Una vez tenga ese dato como probado,lea de esa linea los 3 primeros carecteres y los vuelque y cree el primer td y tome luego el valor pos 23 y lea los 3 caracteres y los copie en el siguiente td. así varios valores.

<TR><TD>IB </TD><TD>MAD</TD><TD>
Una vez termine la primera linea. lea las siguientes lineas y cree sus tablas y valores.
Me gustaría que me echaran una mano. No se si existe alguna forma de poder realizar esto.

eh visto algo como esto
<HTML>
<BODY>


<input type="file" id="file-input" />
<h3>Contents of the file:</h3>
<pre id="file-content"></pre>
<script>
function readSingleFile(e) {
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
displayContents(contents);
};
reader.readAsText(file);
}

function displayContents(contents) {
var element = document.getElementById('file-content');
element.innerHTML = contents;
}

document.getElementById('file-input')
.addEventListener('change', readSingleFile, false);
</script>
</BODY>
</HTML>

Si me pueden ir orientando
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder