Home  >  Article  >  Web Front-end  >  js reads csv files and displays them using json_javascript skills

js reads csv files and displays them using json_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:21:211809browse

Summary:

I shared earlier that I used js to download json data into csv files to facilitate later management. However, testers prefer to display tasks in the form of pages, so I made an example of displaying csv files on the page.

Code:

Copy code The code is as follows:





csv





                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                   
                                                                                                                            
                                                                                                                                                                             
VehicleLocationSpeed

<script><br> Papa.parse('./Result.csv', {<br>         download: true,<br> Complete: function(results) {<br>           var data = results.data, html;<br> for(var i = 1, _l = data.length-1; i < _l; i ) {<br />               var item = data[i];<br /> html = '<tr><td>' item[0].substring(1) '</td><td>' item[1].substring(1) '</td><td&gt ;' item[2].substring(1) '</td><td>' item[3].substring(1) '</td></tr>';<br>             }<br>                  $('#table tbody').append(html);<br> }<br> });<br> </script>





Rendering:



Note: The above example requires a service environment
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn