Help with CSV Data

Help with CSV Data

hahaxd3hahaxd3 Posts: 2Questions: 1Answers: 0

Hi guys,
at first i want to say i'm from Germany and my english is not perfect haha.
I must create a Table. My table must look like the Datatable.
and when i edit my table the csv must edit to. i can say i mean the tabe and the csv must be sync.
And my biggest problem is i have no experience with php jquery or something else.
I hope you can read the text and can help me :)

Answers

  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin

    DataTables as a CSV export option provided by TableTools. Is that what you mean by CSV?

    There is no built in option in DataTables to read CSV data, you would need to import to Javascript arrays / objects yourself.

    Allan

  • hahaxd3hahaxd3 Posts: 2Questions: 1Answers: 0

    i dont want to export the csv. I have a csv and i want import the csv to datatable.The taple must be changeable and looks like the exaple on the homepage. It will be very nice.

  • loukinglouking Posts: 259Questions: 52Answers: 0
    edited September 2015

    I recently had to do this. d3js has a nice set of import functions which can be used together with datatables. Note this was adapted from http://stackoverflow.com/questions/29256675/integrate-datatables-plugin-with-the-help-of-d3-js

    // assumes empty table in DOM before call
    function datatables_csv(fileuri, tableid, dtoptions) {
      if (typeof dtoptions === 'undefined') { dtoptions = {}; }
    
      d3.text(fileuri, function (datasetText) {
    
        var rows = d3.csv.parseRows(datasetText);
    
        var tbl = d3.select("#" + tableid);
    
        // headers
        tbl.append("thead").append("tr")
          .selectAll("th")
            .data(rows[0])
          .enter().append("th")
            .text(function(d) { return d; });
    
        // data
        tbl.append("tbody")
          .selectAll("tr")
              .data(rows.slice(1))
          .enter().append("tr")
            .selectAll("td")
              .data(function(d){ return d; })
            .enter().append("td")
              .text(function(d){ return d; });
    
        jQuery(document).ready(function() {
          jQuery("#" + tableid).DataTable(dtoptions);
        });
    
      });
    }
    
This discussion has been closed.