Import Data
Import Data
john007
Posts: 3Questions: 2Answers: 0
How can you import data into datatables? Is there a simple way to bring a .csv into datatables?
This discussion has been closed.
Answers
You could Ajax load the CSV file and then break it up into an array or objects before then passing that data to DataTables. That would probably be the most direct way of doing it.
Allan
It seems strange that there isn't a simpler way to do this. I searched quite a bit for a good way to do it and they all require either php, javascript or some other scripting language in order to make a .csv into a table. I'm surprised there isn't a plugin in excel that makes spreadsheets into html tables or one for datatables that allows you to import them.
I don't think you need any PHP or any other server-side language. As I say, you could just Ajax get the CSV file (or have an upload option using
FileReader
) and break it up into Javascript arrays - a trivialfor
loop would do that. Then feed the resulting data to DataTables -data
.Allan