我有一个CSV文件:
2011-01-11, 0:00, 4
2011-01-11, 0:05, 2
2011-01-11, 0:10, 6
2011-01-11, 0:15, 8
...
2011-01-12, 0:00, 4
2011-01-12, 0:05, 2
...
2011-01-13, 20:00, 4
2011-01-13, 20:05, 2
...
仅显示最近48小时数据的最佳做法是什么?
以下是CSV解析器:
$.get('data.csv', function(data) {
// Split the lines
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 {
var series = {
data: []
};
$.each(items, function(itemNo, item) {
if (itemNo == 0) {
series.name = item;
} else {
series.data.push(parseFloat(item));
}
});
options.series.push(series);
}
});
修改此解析器以仅从CSV加载最后288行(24小时数据)是一种好方法吗?如果是的话,我怎么能这样做?