A Pen by WEB SYS CS on CodePen.
Last active
March 26, 2020 13:27
-
-
Save t1089/de659a52503b8a24fd72cd18b348e22b to your computer and use it in GitHub Desktop.
Live Novel Coronavirus (confirmed COVID-19) per country or region.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script> | |
| <title>js-tutorials.com : Reading CSV file using jQuery </title> | |
| </head> | |
| <body> | |
| <div class="container" style="padding:10px 10px;"> | |
| <div id="header"></div> | |
| <div class="well"> | |
| <div class="row" id="csv-display" style="height:500px;overflow: scroll;"> | |
| </div> | |
| </div> | |
| <div class="col-sm-10" style="margin:20px 0px 20px 0px;"> | |
| </div> | |
| <div id="footer"></div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| var data; | |
| $.ajax({ | |
| type: "GET", | |
| url: "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv", | |
| dataType: "text", | |
| success: function(response) | |
| { | |
| data = $.csv.toArrays(response); | |
| generateHtmlTable(data); | |
| } | |
| }); | |
| function generateHtmlTable(data) { | |
| var html = '<table class="table table-condensed table-hover table-striped">'; | |
| if(typeof(data[0]) === 'undefined') { | |
| return null; | |
| } else { | |
| $.each(data, function( index, row ) { | |
| //bind header | |
| if(index == 0) { | |
| html += '<thead>'; | |
| html += '<tr class="dwf">'; | |
| $.each(row, function( index, colData ) { | |
| html += '<th class="overturning">'; | |
| html += colData; | |
| html += '</th>'; | |
| }); | |
| html += '</tr>'; | |
| html += '</thead>'; | |
| html += '<tbody>'; | |
| } else { | |
| html += '<tr>'; | |
| $.each(row, function( index, colData ) { | |
| html += '<td>'; | |
| html += colData; | |
| html += '</td>'; | |
| }); | |
| html += '</tr>'; | |
| } | |
| }); | |
| html += '</tbody>'; | |
| html += '</table>'; | |
| $('#csv-display').append(html); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment