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>
    

      

  • 相关阅读:
    排球训练营
    TP5中手机端和PC端判断
    N550JV无法休眠,休眠自动重启的原因及解决方法
    HTML标签全称
    HTML思维导图
    HTML基础
    Web项目流程
    VsCode使用之HTML 中 CSS Class 智能提示
    MyEclipse崩溃 Java was started but returned exit code=-1073740791
    Python 类的特殊成员方法
  • 原文地址:https://www.cnblogs.com/wzihan/p/13088790.html
Copyright © 2011-2022 走看看