简体   繁体   中英

Refresh View when file changes - CsvToHtmlTable library

I am working on converting an CSV into a Table in Javascript - so far so good, this is the piece of code who does it:

 CsvToHtmlTable.init({
        csv_path: 'data/Tasks.csv',
        element: 'table-container', 
        allow_download: false,
        csv_options: {separator: ',', delimiter: '"'},
        datatables_options: {"paging": false},
        custom_formatting: [[4, format_link]]
     });

Since Tasks.csv gets updated every 5min I would like my table to be redrawn when that happens. I cannot find any configuration options to achieve so in that library ( https://github.com/derekeder/csv-to-html-table ) and I have no clue how to implement it myself.

Also the all project consist in one simple index.html page with the Javascript script in it so no much else to show really.

Any ideas?

just re-execute the code

CsvToHtmlTable.init({
    csv_path: 'data/Tasks.csv',
    element: 'table-container', 
    allow_download: false,
    csv_options: {separator: ',', delimiter: '"'},
    datatables_options: {"paging": false},
    custom_formatting: [[4, format_link]]
 });

as and when, your CSV get's refresh, that is after a certain period like 5/6 minutes. You can use window.setInterval method, which keeps on executing after certain time interval. Reference Link: https://www.w3schools.com/jsref/met_win_setinterval.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM