Add column headers to CSV file

i want t create a csv file with header
i follow this example but doesn't work. i always find the header's names in one cell ?

[{"id":"1993503b.2a2d88","type":"fs-ops-access","z":"456ce3eb.038f9c","name":"","path":"measurements","pathType":"str","filename":"test.csv","filenameType":"str","read":false,"write":true,"throwerror":false,"x":270,"y":540,"wires":[["f5a19eb1.8cf848"],["58e35a35.3ba4e4"]]},{"id":"d0c0fa9b.978bf","type":"inject","z":"456ce3eb.038f9c","name":"","topic":"test","payload":"15,20,25,30","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":500,"wires":[["1993503b.2a2d88"]]},{"id":"f5a19eb1.8cf848","type":"file","z":"456ce3eb.038f9c","name":"Save to file","filename":"measurements/test.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","x":590,"y":500,"wires":[]},{"id":"58e35a35.3ba4e4","type":"function","z":"456ce3eb.038f9c","name":"add time","func":"msg.payload = \"Title1,title2,title3\" +\"\\n\"+ msg.payload;\nmsg.error = null;\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":560,"wires":[["f5a19eb1.8cf848"]]}]

Any help !! And thanks in advance.

i was trying to create a csv file and put each message on payload in row.
here's a screen shot of what i get !
image
[{"id":"efbe8950.cc5658","type":"file","z":"e9466292.f6b17","name":"store2.csv","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","x":550,"y":760,"wires":[]},{"id":"8b1f8ed7.46751","type":"csv","z":"e9466292.f6b17","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\r\n","temp":"a,b,c","skip":"0","x":350,"y":760,"wires":[["efbe8950.cc5658"]]},{"id":"2c499cc2.cde794","type":"function","z":"e9466292.f6b17","name":"","func":"msg.payload = [\n { a: 80, b: 18, c: 2},\n { a: 52, b: 36, c: 10},\n { a: 91, b: 18, c: 61},\n { a: 32, b: 47, c: 65},\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":760,"wires":[["8b1f8ed7.46751"]]},{"id":"8b3290d3.6d043","type":"inject","z":"e9466292.f6b17","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":700,"wires":[["2c499cc2.cde794"]]}]

any suggestion Please !!!

From the little I can see on my phone that looks fine. Looks like the import isn’t handling it

thanks. iyou can import it now!!
i don't understand where is the problem ?

Any advice here ???!! it was working month ago, but now i don't what's happened ?!

What problem are you trying to solve?

Your second flow doesn’t include any attempt to add column headers which is the tile of the thread.

the CSV node doesn't have the output names selected - and no line ending set...
but the output you show looks ok. (you don't append the actual file produced.)

[{"id":"b605cbe1.3e38c8","type":"csv","z":"3658255b.2041aa","name":"","sep":",","hdrin":"","hdrout":true,"multi":"one","ret":"\\n","temp":"a,b,c","skip":"0","strings":true,"x":350,"y":400,"wires":[["866f2ce2.66549"]]},{"id":"578c6f59.dbdb3","type":"function","z":"3658255b.2041aa","name":"","func":"msg.payload = [\n { a: 80, b: 18, c: 2},\n { a: 52, b: 36, c: 10},\n { a: 91, b: 18, c: 61},\n { a: 32, b: 47, c: 65},\n];\n\nreturn msg;\n","outputs":1,"noerr":0,"x":190,"y":400,"wires":[["b605cbe1.3e38c8"]]},{"id":"76ffaf2f.75f6d","type":"inject","z":"3658255b.2041aa","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":340,"wires":[["578c6f59.dbdb3"]]},{"id":"866f2ce2.66549","type":"debug","z":"3658255b.2041aa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":520,"y":340,"wires":[]}]

yeah, i was attempting to add headers but it seems that i have another problem on storing data on csv file.!!!?
is it because the new updates on node-red nodes ?
And How it does it work now ?

the example I shared works for me with latest so I don't know. can you share the file it produces ?

Sans%20titre
here's my file!

Found it! it was in changing separator in csv node with semicolon ";".
Thank you Sirs for help.

Hi everyone,
i want to edit header name in my csv file. i have any idea and i cannot find solution in froum. Have any Idea?

Tnx
Samira

@Samira05 since this thread is two years old please open a new thread and explain what you have tried and show an example. It is not clear if you are already sending column headers and want to change them or if it is something else.

I will close this thread and wait to see your new thread.

1 Like