How do I convert a csv file into a chart?

I've been having such a hard time understanding how to use Node Red's functionality in reading a csv file and converting it into a scatter plot chart.

I have a CSV file that looks like this:
09-16-1989, 45

09-16-1990, 50

09-16-1991, 33

09-16-1992, 23

....
It has over 88,909 lines but I need to have the date on the x-axis and the other numerical value on the y-axis. I have looked through multiple resources but nothing helps because no such basic tutorial exists.

Does this help: Problem with X/Y graph with ui_graph - #8 by Steve-Mcl

You want to show a scatter plot with 89000 points on it? I think that may impose quite a load on the browser.
I think you may need to rationalise the data before plotting it.

I'm just trying to get Node Red to read a csv file and then plot it. I don't understand why its so difficult and its actually simpler to write it in code in Python or any other high level language, but in Node Red its almost an impossible task. What am I missing here? No one in the class even knows what is going on

No, I'm sorry it doesn't. I tried your code but nothing shows up, its just blank so I'm not sure what is going on for the dashboard and I feel that it has something to do with Node Red's design.

Can you share your flow in its current state. I will also need a sample file.

Use ctrl-e to export flow.

Hi, this is the exported code. I've talked to my peers and we tried everything, it doesn't make sense and looked everywhere on the web. I am using a pathfile from my C drive.

Also I am testing a file that looks like this:
13:53 127.96
13:53 24.65
13:53 24.49
13:53 24.9

Below is the code. Nothing here makes any sense, I have no working example and cannot see a chart.

[
    {
        "id": "6db4358edc7b4457",
        "type": "tab",
        "label": "graph csv",
        "disabled": false,
        "info": ""
    },
    {
        "id": "e3866b5b6346eb39",
        "type": "inject",
        "z": "6db4358edc7b4457",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 260,
        "wires": [
            [
                "e86d09d18c0b7c89"
            ]
        ]
    },
    {
        "id": "716fe4e286cfc31d",
        "type": "csv",
        "z": "6db4358edc7b4457",
        "name": "",
        "sep": "\\t",
        "hdrin": false,
        "hdrout": "none",
        "multi": "mult",
        "ret": "\\n",
        "temp": "x,y",
        "skip": "0",
        "strings": true,
        "include_empty_strings": false,
        "include_null_values": false,
        "x": 388,
        "y": 160,
        "wires": [
            [
                "9f367c358a0f5f4b"
            ]
        ]
    },
    {
        "id": "9f367c358a0f5f4b",
        "type": "function",
        "z": "6db4358edc7b4457",
        "name": "Format data for chart",
        "func": "for(let i = 0; i< msg.payload.length; i++){\n    let time_parts = msg.payload[i].x.split(\":\");\n    msg.payload[i].x = (Number(time_parts[0]) * 3600000) +(Number(time_parts[1]) * 60000) + (i *10000)\n}\n\n\nmsg.payload = [{\n    \"series\":[\"temp\"],\n    \"data\":[msg.payload],\n    \"labels\":[]\n}];\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 160,
        "wires": [
            [
                "39434efb498c3b99",
                "a1c0b3c99da7c008"
            ]
        ]
    },
    {
        "id": "39434efb498c3b99",
        "type": "debug",
        "z": "6db4358edc7b4457",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 910,
        "y": 120,
        "wires": []
    },
    {
        "id": "a1c0b3c99da7c008",
        "type": "ui_chart",
        "z": "6db4358edc7b4457",
        "name": "",
        "group": "160e81fb.f1c86e",
        "order": 12,
        "width": "18",
        "height": "6",
        "label": "",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 920,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "e86d09d18c0b7c89",
        "type": "file in",
        "z": "6db4358edc7b4457",
        "name": "",
        "filename": "pathfile",
        "filenameType": "str",
        "format": "lines",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 100,
        "y": 80,
        "wires": [
            [
                "716fe4e286cfc31d"
            ]
        ]
    },
    {
        "id": "160e81fb.f1c86e",
        "type": "ui_group",
        "name": "File Browser",
        "tab": "5b94a1d5e0dbd838",
        "order": 3,
        "disp": true,
        "width": "18",
        "collapse": false,
        "className": ""
    },
    {
        "id": "5b94a1d5e0dbd838",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

All you have posted is a single file node. Select all nodes of interest before exporting

Also...

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

If you put a debug after the csv node what do you get? I ran your flow with a template

13:53   127.96
13:53   24.65
13:53   24.49
13:53   24.9

The cvs does not appear to recognise the tabs in the cvs file.

here is an example both templates look the same and the second was created with the tab key, but does not act like a tab and looks different in the debug panel.

[{"id":"c568e8c2.fde8d","type":"inject","z":"6db4358edc7b4457","name":"working proper tabs","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":60,"wires":[["620cc922.3966c"]]},{"id":"620cc922.3966c","type":"template","z":"6db4358edc7b4457","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"13:53\t127.96\n13:53\t24.65\n13:53\t24.49\n13:53\t24.9\n","output":"str","x":200,"y":140,"wires":[["716fe4e286cfc31d","39434efb498c3b99"]]},{"id":"716fe4e286cfc31d","type":"csv","z":"6db4358edc7b4457","name":"","sep":"\\t","hdrin":false,"hdrout":"none","multi":"mult","ret":"\\n","temp":"x,y","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":370,"y":160,"wires":[["9f367c358a0f5f4b"]]},{"id":"39434efb498c3b99","type":"debug","z":"6db4358edc7b4457","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":120,"wires":[]},{"id":"d14a24c2.2ae0a","type":"template","z":"6db4358edc7b4457","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"13:53   127.96\n13:53   24.65\n13:53   24.49\n13:53   24.9\n","output":"str","x":210,"y":220,"wires":[["716fe4e286cfc31d","39434efb498c3b99"]]},{"id":"9f367c358a0f5f4b","type":"function","z":"6db4358edc7b4457","name":"Format data for chart","func":"for(let i = 0; i< msg.payload.length; i++){\n    let time_parts = msg.payload[i][\"x\"].split(\":\");\n    msg.payload[i][\"x\"] = (Number(time_parts[0]) * 3600000) +\n                    (Number(time_parts[1]) * 60000) + (i *10000)\n}\n\n\nmsg.payload = [{\n    \"series\":[\"temp\"],\n    \"data\":[msg.payload],\n    \"labels\":[]\n}];\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":160,"wires":[["39434efb498c3b99"]]},{"id":"2973079.9665a78","type":"inject","z":"6db4358edc7b4457","name":"not working tabs are spaces","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":280,"wires":[["d14a24c2.2ae0a"]]}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.