Hey!
We truly hope that our free tool comes in handy for your business, especially these days. Follow our news, stay safe & pivot on!

Can I update data from the same source csv?

Resolved

Hello,
I have successfully set-up a pivot report by reading data from a .csv file.
This file gets constantly updated, hence I was looking for a way to update the results of my report without losing the structure.
I have tried to use the UpdateDataCSV function, but data don’t get refreshed.
 
Does anybody know why?
 
 
Here my code:
 
 
function updateDataCSV() {
        webdatarocks.updateData({
            filename: “<?php echo site_url(‘uploads/DataCube/DataCube.csv’); ?>”
        });
    }
    var pivot = new WebDataRocks({
    container: “#wdr-component”,
    toolbar: true,
    report: {
    dataSource: {
    filename: “<?php echo site_url(‘uploads/DataCube/DataCube.csv’); ?>”
    }, 
        “slice”: {
        “reportFilters”: [
            {
                “uniqueName”: “RLR Responsible”
            },
            {
                “uniqueName”: “Site Group”
            },
            {
                “uniqueName”: “Quarter”
            }
        ],
        “rows”: [
            {
                “uniqueName”: “Site Code”
            },
            {
                “uniqueName”: “Site Name”
            }
        ],
        “columns”: [
            {
                “uniqueName”: “Year”
            },
            {
                “uniqueName”: “Measures”
            }
        ],
        “measures”: [
            {
                “uniqueName”: “ACT (GC)”,
                “aggregation”: “sum”
            },
            {
                “uniqueName”: “Forecast (GC) @ Current BDG Rate”,
                “aggregation”: “sum”
            },
            {
                “uniqueName”: “Annual BDGget (GC) @ Current BDG Rate”,
                “aggregation”: “average”
            },
            {
                “uniqueName”: “Best Estimate (GC) @ Current BDG Rate”,
                “aggregation”: “average”
            },
            {
                “uniqueName”: “Cash Proj (LC)”,
                “aggregation”: “average”
            },
            {
                “uniqueName”: “Cash Proj. (GC) @ Current BDG Rate”,
                “aggregation”: “average”
            }
        ]
    },
    “options”: {
        “grid”: {
            “type”: “classic”,
            “showTotals”: “off”,
            “showGrandTotals”: “columns”
        }
    },
    “formats”: [
        {
            “name”: “”,
            “thousandsSeparator”: “,”,
            “decimalSeparator”: “.”,
            “decimalPlaces”: 2,
            “currencySymbol”: “”,
            “currencySymbolAlign”: “left”,
            “nullValue”: “”,
            “textAlign”: “right”,
            “isPercent”: false
        }
    ]              
    }
    });
 
Many thanks,
Enrico

2 answers

WebDataRocks Team WebDataRocks March 23, 2020

Hello, Enrico,
 
Thank you for contacting us.
 
We would like to kindly explain that calling the updateData method with the previously specified parameters will be considered as a similar request and ignored by the component.
 
In order to force the update, the following approach can be applied:
Each time the data needs to be updated, the new URL parameter should be specified.
For example, the following construction can be used:

webdatarocks.updateData({
filename: "url" + "?" + new Date().getTime()
});

 
We hope it works for you.
 
You are welcome to contact us in case additional questions arise.
 
Best regards,
WebDataRocks Team

Enrico March 23, 2020

Thank you for your feedback.
The solution you proposed works well!
 
Many thanks,
Enrico

Please login or Register to Submit Answer