模拟读取CSV数据文件,查找标题行和数据行

模拟读取CSV数据文件,查找标题行和数据行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
  <script>
    var lineData=new Array(
    "",
    "a1,22,33,44,55,66,77,88,99,00,11,22",
    "a2,22,33,44,55,66,77,88,99,00,11,22,33",
    "",
    "",
    "a3,22,33,44,55,66,77,88,99,00,11,22",
    "a4,22,33,44,55,66,77,88,99,00,11,22",
    "a5,22,33,44,55,66,77,88,99,00,11,22,33",
    "a6,22,33,44,55,66,77,88,99,00,11,22,33");
 
    function getHeadLine(lineData){
        var retHeadLine = 0;
        for (i = 0; i < lineData.length -1 ; i++)
        {
            if ( lineData[i] == "" )
            {
                continue;
            }
 
            var objLines = lineData[i].split(",");
            if ( objLines.length == 13 )
            {
                retHeadLine = i;
                break;
            }
        }
        alert(retHeadLine);
        return retHeadLine;
    }
 
    function getDataLine(lineData,iStart){
        var retHeadLine = 0;
        for (i = iStart; i < lineData.length -1 ; i++)
        {
            if ( lineData[i] == "" )
            {
                continue;
            }
 
            var objLines = lineData[i].split(",");
            if ( objLines.length == 13 )
            {
                retHeadLine = i;
                break;
            }
        }
        alert(retHeadLine);
        return retHeadLine;
    }
 
  </script>
  <form method="post" action="">
    <input type="button" value="getHeadLine" onclick="return getDataLine(lineData,0);">
    <input type="button" value="getDataLine" onclick="return getDataLine(lineData,(2+1));">
</form>
 </body>
</html>

  

posted @   奥兰王子  阅读(454)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
点击右上角即可分享
微信分享提示