17-05-2021 - Create a .csv file with data
Mission:
Create a .csv file for every week of the year, in the IoT with the data.
Solution:
Node red is your friend. Sit and relax.
Step 1 - Update the S7 node.Add the following data requests to the PLC s7 node:


Step 2 - Create a file directory.
root@iot2000:~# cd /home
root@iot2000:/home# ls
root@iot2000:/home# mkdir files
root@iot2000:/home# ls
root@iot2000:/home# cd files
root@iot2000:/home/files# ls
Step 3 - Get the data with the .csv node.
Description of the .csv node.
Drag a .csv node into the flow and configure it.

For convenience, put debug nodes where necessary.
Step 4 - Save the data with the file node.
Drag a file node in the flow abd configure it.

Step 5 - Check if the file is written and check its contents
root@iot2000:~# cd /home/files
root@iot2000:/home/files# ls

Check the content of the file:
root@iot2000:/home/files# nano s7output.csv

Here is a download link to the json flow so far.
Step 6 - Create the filename
If we want to create a .csv file for every week, we have to create a dynamic file name.
This can be done with a function node.
Insert a funtion node and enter the following functions.

This function wil create a filename like yyyyWKxx.csv. yyyy is the year, xx is the weeknumber.
Here is a download link to the completed json flow.
