I'm trying to import a local CSV file with headings into a local HTML file, which will then display as a table in a browser.
I haven't been learning HTMLand JavaScript for long, so I don't know a lot about importing and converting. What I need is some advice or possibly a basic script describing the sort of function I need. Explanations and advice are all welcomed!
This is an example of the csv file:
heading1,heading2,heading3,heading4,heading5
value1_1,value1_2,value1_3,value1_4,value1_5
value2_1,value2_2,value2_3,value2_4,value2_5
value3_1,value3_2,value3_3,value3_4,value3_5
value4_1,value4_2,value4_3,value4_4,value4_5
value5_1,value5_2,value5_3,value5_4,value5_5
This is how I'd want to display it:
http://jsfiddle.net/yekdkdLm
To display the data from CSV file to web browser, we will use fgetcsv() function. Comma Separated Value (CSV) is a text file containing data contents. It is a comma-separated value file with .
<div id="CSVTable"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//jquerycsvtotable.googlecode.com/files/jquery.csvToTable.js"></script>
<script>
$(function() {
$('#CSVTable').CSVToTable('your_csv.csv');
});
</script>
you can use jquery.csvToTable.js to display csv file in html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With