Foros del Web » Programando para Internet » Javascript »

importar y filtrar archivo csv

Estas en el tema de importar y filtrar archivo csv en el foro de Javascript en Foros del Web. Hola a todos y enhorabuena por este foro. Tengo un problema el cual soy incapaz de resolver por mi mismo: este archivo csv: Cita: Categorias,18/10/2012 ...
  #1 (permalink)  
Antiguo 24/10/2012, 11:06
 
Fecha de Ingreso: enero-2012
Mensajes: 24
Antigüedad: 12 años, 2 meses
Puntos: 1
importar y filtrar archivo csv

Hola a todos y enhorabuena por este foro.

Tengo un problema el cual soy incapaz de resolver por mi mismo:

este archivo csv:

Cita:
Categorias,18/10/2012 21:00,18/10/2012 22:00,18/10/2012 23:00,19/10/2012 00:00,19/10/2012 01:00,19/10/2012 02:00,19/10/2012 03:00,19/10/2012 04:00,19/10/2012 05:00,19/10/2012 06:00,19/10/2012 07:00,19/10/2012 08:00, 19/10/2012 09:00,19/10/2012 10:00,19/10/2012 11:00,19/10/2012 12:00,19/10/2012 13:00,19/10/2012 14:00,19/10/2012 15:00,19/10/2012 16:00,19/10/2012 17:00,19/10/2012 18:00,9/10/2012 19:00,19/10/2012 20:00,
Precipitacion,1.4,1.2,0.8,1,0.2,1.4,1.4,1.6,0.8,1, 0.2,0,0,0,0.2,0,0,0,0,0,0,0,0,0
Temperatura,9.9,9.5,9,8.7,8.7,8.5,8.6,8.3,8.3,8,7. 8,7.6,7.4,7.3,8.6,12.7,13.7,14.5,15.1,15.1,13.9,13 .7,12.8,12.2
Presion,966.3,966.1,966.5,966.4,966.7,966.8,967.5, 967.3,967.2,967.9,967.9,968.2,968.7,969.3,969.8,96 9.9,970.3,970.3,970.1,970,970.6,971,971.4,972.2
lo interpreta perfectamente este código

Cita:
var lines = data.split('\n');
$.each(lines, function(lineNo, line) {
var items = line.split(',');

// header line containes categories
if (lineNo === 0) {
$.each(items, function(itemNo, item) {
if (itemNo > 0) options.xAxis.categories.push(item);
});
}


// the rest of the lines contain data with their name in the first position
else {


$.each(items, function(itemNo, item) {
if (itemNo === 0) {
options.series[lineNo-1].name = item;

} else {
options.series[lineNo-1].data.push(parseFloat(item));
}
});

}

});
Pues bien, todo correcto. El problema se me presenta cuanto intento leer este otro csv, el cual solo necesito las columnas que remarcadas en rojo, se que es un poco complicado pero quizás alguno de ustedes me pueda ayudar.

Cita:
"Tineo"
Actualizado: viernes, 12 octubre 2012 a las 22:32 hora oficial

"Fecha y hora oficial","Temperatura (ºC)","Velocidad del viento (km/h)","Dirección del viento","Racha (km/h)","Dirección de racha","Precipitación (mm)","Presión (hPa)","Tendencia (hPa)","Humedad (%)"
"12/10/2012 22:00","12.5","2","Sudeste","3","Sudeste","0.0","9 79.6","0.3","86"
"12/10/2012 21:00","12.7","0","Calma","4","Este","0.0","979.7" ,"0.4","82"
"12/10/2012 20:00","13.0","0","Calma","4","Oeste","0.0","979.7 ","0.0","79"
"12/10/2012 19:00","13.4","3","Sudeste","5","Sudeste","0.0","9 79.3","-0.6","80"
"12/10/2012 18:00","13.5","0","Calma","4","Oeste","0.0","979.3 ","-1.2","84"
"12/10/2012 17:00","13.3","2","Oeste","5","Noroeste","0.0","97 9.7","-1.4","83"
"12/10/2012 16:00","13.5","5","Sudoeste","8","Oeste","0.0","97 9.9","-1.6","87"
"12/10/2012 15:00","12.2","5","Oeste","8","Oeste","0.2","980.5 ","-0.9","89"
"12/10/2012 14:00","11.3","5","Oeste","7","Oeste","0.2","981.1 ","0.0","95"
"12/10/2012 13:00","11.0","10","Noroeste","17","Noroeste","0.6 ","981.5","0.7","99"
"12/10/2012 12:00","12.2","2","Sudoeste","5","Sudoeste","0.0", "981.4","1.7","98"
"12/10/2012 11:00","11.7","5","Sudeste","8","Este","0.0","981. 1","1.9","100"
"12/10/2012 10:00","10.7","6","Noroeste","8","Noroeste","0.0", "980.8","1.8","100"
"12/10/2012 09:00","10.5","5","Sudoeste","6","Sudoeste","0.0", "979.7","1.4","100"
"12/10/2012 08:00","10.6","5","Sur","9","Sur","0.2","979.2","1 .1","100"
"12/10/2012 07:00","10.9","11","Noroeste","19","Noroeste","1.0 ","979.0","0.4","100"
"12/10/2012 06:00","11.0","3","Norte","5","Sudoeste","0.0","97 8.3","0.0","100"
"12/10/2012 05:00","10.8","2","Noroeste","5","Oeste","0.6","97 8.1","-0.1","100"
"12/10/2012 04:00","11.2","10","Noroeste","21","Noroeste","1.6 ","978.6","0.7","100"
"12/10/2012 03:00","11.7","5","Oeste","8","Oeste","0.2","978.3 ","0.7","100"
"12/10/2012 02:00","12.1","10","Oeste","28","Oeste","0.2","978 .2","1.1","100"
"12/10/2012 01:00","12.3","6","Oeste","9","Oeste","0.0","977.9 ","1.4","100"
"12/10/2012 00:00","12.2","7","Oeste","11","Oeste","0.0","977. 6","1.6","100"
"11/10/2012 23:00","12.1","6","Noroeste","12","Noroeste","0.2" ,"977.1","1.9","100"

Última edición por raposu; 24/10/2012 a las 14:43

Etiquetas: csv, filtrar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:20.