[closed] syntax to append data to textfile

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
BartSr
Posts: 491
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

[closed] syntax to append data to textfile

Post by BartSr »

I am struggeling to get data append to existing textfile

Code: Select all

 file = io.open("/home/pi/gas.txt", "w+") 
   	file:write("gasstand"..gasstand.."\n")
        file:close() --closes the open file
I borrowed this code partly from a script written by Waaren. It was understood thet the w+ should open the file in append mode.
But every time there is only the new data in the file gas.txt

Where is my error? And where can I find info re create a file if not already exist? To my knowledge quit native but the syntax.....

Thanks
-Bart
Last edited by BartSr on Tuesday 07 March 2023 23:43, edited 1 time in total.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: <2025
Location: Hengelo(Ov)/NL
Contact:

Re: syntax to append data to textfile

Post by Toulon7559 »

See the first list under this weblink:
https://www.tutorialspoint.com/python/p ... les_io.htm#
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
BartSr
Posts: 491
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

Re: syntax to append data to textfile

Post by BartSr »

Toulon7559, Thanks a lot. You helped me out!
-Bart
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest