zoukankan      html  css  js  c++  java
  • 模拟读取CSV数据文件,查找标题行和数据行

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

    <!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>
    

      

  • 相关阅读:
    清除浮动
    echarts设置小图标位置
    dedecms 顶级栏目内容显示
    dedecms 后台网站 标题设置
    mouseover,mouseenter,mouseout,mouseleave的区别
    texterea 水平居中
    echarts x轴文字换行显示
    echarts 拐点添加图片
    css首行缩进2个字符
    bootstrap 内边框样式
  • 原文地址:https://www.cnblogs.com/wzihan/p/13088790.html
Copyright © 2011-2022 走看看