Import Data

Import Data

john007john007 Posts: 3Questions: 2Answers: 0

How can you import data into datatables? Is there a simple way to bring a .csv into datatables?

Answers

  • allanallan Posts: 61,916Questions: 1Answers: 10,150 Site admin

    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

  • john007john007 Posts: 3Questions: 2Answers: 0

    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.

  • allanallan Posts: 61,916Questions: 1Answers: 10,150 Site admin

    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 trivial for loop would do that. Then feed the resulting data to DataTables - data.

    Allan

This discussion has been closed.