Hi,
i have a data collector (DS18B20), collect 200 samples and write the data in a .csv file. The filename is composed from date and time, resulting in filenames like '2024-11-30 18:17.csv'
This is how i can read it in the directory on the raspi.
To have external access to the file i installed samba, added a user and configured the smb.conf.
The folder is available now on other PC's. (Windows ans Mint)
The problem is, the filename looks like W2VCD0~.csv.
The write file node allows several options like utf8, standard etc. I tried some of them, did not change anything.
Any ideas?
Thank you in advance.
Hi @alexander77 - as with all queries like this. - please provide us a flow export that is creating the files, we might be able to see something.
Shure.
Date and time are generated with the simpletime node.
var datum = msg.myymd;
var zeit = msg.mytime;
msg.filename reads as follows:
filename: "/home/raspi/public/2024-11-30 21:24.csv"
var howmany = msg.payload;
var out = "";
var time = flow.get("time"); // das ist die liste
var zeit = flow.get("zeit");
var date = flow.get("date"); // das ist die liste
var datum = flow.get("datum"); // das ist die aktuelle zeit
var sensor1 = flow.get("sensor1");
var sensor2 = flow.get("sensor2");
var sensor3 = flow.get("sensor3");
var sensor4 = flow.get("sensor4");
var sensor5 = flow.get("sensor5");
var sensor6 = flow.get("sensor6");
var sensor7 = flow.get("sensor7");
var sensor8 = flow.get("sensor8");
var sensor9 = flow.get("sensor9");
var sensor10 = flow.get("sensor10");
var sensor11 = flow.get("sensor11");
var index = 1;
out = "Datum;Zeit;Sensor1;Sensor2;Sensor3;Sensor4;Sensor5;Sensor6;Sensor7;Sensor8;Sensor9;Sensor10;Sensor11"+ "\x0d\x0a";
msg.filename = "/home/raspi/public/" + datum + " " + zeit + ".csv";
while (index < howmany) {
out = out + date[index] + ";" + time[index] + ";" + sensor1[index] + " ; " + sensor2[index] + " ; " + sensor3[index] + ";" + sensor4[index] + ";" + sensor5[index] + ";" + sensor6[index] + ";" + sensor7[index] + ";" + sensor8[index] + ";" + sensor9[index] + ";" + sensor10[index] + ";" + sensor11[index] + "\x0d\x0a";
index +=1;
}
msg.payload = out;
return msg;
You know windows doesn't have :
support in file names?
and if using samba - might be some odd behaviour happening
May I suggest simplifying it - with a change
node to set the filename
?
(changing the timezone to suite of course)
[{"id":"3a86f84d81ec95fd","type":"change","z":"2d7bf6e3.84c97a","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"$moment().tz('Europe/London').format('DD.MM.YYYY-HH.mm') & '.csv'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":640,"wires":[["2c78e4eb788fde4a"]]},{"id":"e3bfc6ee29ee332b","type":"inject","z":"2d7bf6e3.84c97a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":700,"wires":[["3a86f84d81ec95fd"]]},{"id":"2c78e4eb788fde4a","type":"debug","z":"2d7bf6e3.84c97a","name":"debug 386","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":680,"wires":[]}]
Get rid of spaces in the filenames too.
I suggest 202411302124.csv but make sure everything is zero filled to two places
@alexander77 like this in the change
node
$moment().tz('Europe/London').format('YYYYMMDDHHmm') & '.csv'
Six characters followed by a tilda is for compatibility with old old systems.
From a post on superuser.com (12 years ago but it might still be relevant!)
It's a file name mangling problem. Samba is converting filenames down to old style DOS 8.3 filenames.
Edit
/etc/smb.conf
(*) and addmangled names=no
to the[global]
section and restart the smb service.
Hi,
the way marcus-f-davies suggested works. Will try the entry in smb.conf as well.
Many Thanks, fellows!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.