Hi, I can store data in a file, but the file can grow really big as there are lots of data per second.
May I store the data in a new file each day using a format like 20191031.txt?
Also, is there any function in node red to check the drive free space? If it has only 10Gb left, stop the storage... Thx
Did you read the info for node? The answer is yes you can store data in a new file every day if you want. As you have indicated the logical thing to do would be to use the date as the filename (plus your unique tag perhaps). So you need to get the date in the right format then parse that to the property msg.filename in the File node.
As to the second part of your question, what is the OS that you want to check? And is it the same location as where NR is installed?
It works, Thx. But how to make the new file name everyday? Shall I make a function to check the date and change the file name? If yes, I have done it. :> And how to check the disk free space? Like if there is only 10Gb left, delete the old file or stop writing new file.
I use Window 10 btw.
Thx.
Here is the example I have made.
[{"id":"aa6bb4b0.26b358","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"15055d9.b2a9ca2","type":"file","z":"aa6bb4b0.26b358","name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":650,"y":360,"wires":[]},{"id":"674db817.a9fa08","type":"inject","z":"aa6bb4b0.26b358","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290,"y":360,"wires":[["1233605f.c3a4a"]]},{"id":"1233605f.c3a4a","type":"function","z":"aa6bb4b0.26b358","name":"NewFileName","func":"var newMsg = msg;\nvar date;\ndate = new Date();\ndate = (date.getFullYear() + '-' + ('00' + (date.getMonth()+1)).slice(-2) + '-' + ('00' + date.getDate()).slice(-2));\nnewMsg.filename = "D:/temp/data"+date+".txt";\nreturn newMsg;","outputs":1,"noerr":0,"x":460,"y":360,"wires":[["15055d9.b2a9ca2","f3fc521f.0a7f1","41ca16f7.57d8a8"]]},{"id":"f3fc521f.0a7f1","type":"debug","z":"aa6bb4b0.26b358","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"filename","targetType":"msg","x":660,"y":320,"wires":},{"id":"41ca16f7.57d8a8","type":"debug","z":"aa6bb4b0.26b358","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":280,"wires":}]