Seite 1 von 1

How to save an input value to a file?

Verfasst: 22 Aug 2023, 12:22
von zhengtzer
Hi,


i just bought a txt4.0, in testing how to read/write csv file through python code in robo pro coding

may i ask how?
it is showing in console, just not writing anything to file, anything i did wrong?


thanks
Jonathan

Re: How to save an input value to a file?

Verfasst: 22 Aug 2023, 16:17
von fishfriend
Hallo...
I am not shure.
If the Button ist presed, you want to write -one- time s.t. like utf8 ?
It do not added something to a file. ('a')

Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 22 Aug 2023, 19:01
von zhengtzer
HiHi!!!

[Question 1]
i want to write the word "close" into file everytime i pressed a button
i want to know how to write value into a local file

check user guide, its showing empty~~LOL?
empty_guide.png
empty_guide.png (131.62 KiB) 8785 mal betrachtet
so that i can add timestamp later on and "mimic" IoT locally
as now i seriosuly struggling with ft MQTT


[Question 2]
if doesn't change the file path, where exactly will the file been saved?


until now no luck, need some light here :shock:


thanks
Jonathan

Re: How to save an input value to a file?

Verfasst: 23 Aug 2023, 21:28
von fishfriend
Hallo...
Maybe in Python not in RoboPro Coding.

...
datei = open('test_data.cvs','a')
datei.write("\r\nClose")

so you get:

Close
Close
...
in test_data.cvs

Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 25 Aug 2023, 16:23
von zhengtzer
Hallo,


did you know where is "/home/ftgui" filepath?
ft_writeLocal_02.png
ft_writeLocal_02.png (106.35 KiB) 8614 mal betrachtet

code seem correct, but cant locate the file

tyty
Jonathan

Re: How to save an input value to a file?

Verfasst: 25 Aug 2023, 19:16
von fishfriend
Hallo...
My point of view

os.chdir
only change the path
but in r" "
That ist not the correct name of the path.

The print only show the path where the file test_data.cvs is / is written.

So you find the file test_data.cvs in: home/ftgui/

Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 27 Aug 2023, 08:17
von zhengtzer
Hihi


i have no idea where [home/ftgui/] come from, its not from my pc directory

allow me to post some screenshot, as noticed the file path seem cant be changed
error2.png
error2.png (101 KiB) 8501 mal betrachtet
error3.png
error3.png (33.62 KiB) 8501 mal betrachtet

thanks
Jonathan

Re: How to save an input value to a file?

Verfasst: 27 Aug 2023, 09:31
von fishfriend
Hallo...
Hmmm...
Is there under User... a direktory ...99_trestData ?
And it is in the OneDireve -Cloud?
Maybe ist ist easyer to get only the User/Document dir on your own computer.

Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 28 Aug 2023, 06:42
von zhengtzer
Hi,


the directory had successfully changed
the main issue is, the [home/ftgui], the front part of directory seem unable to change
error4.png
error4.png (14.27 KiB) 8433 mal betrachtet
so the file is written to [home/ftgui] where i dont know where is it :cry:


thanks
Jonathan

Re: How to save an input value to a file?

Verfasst: 28 Aug 2023, 16:19
von fishfriend
Hallo...
RoboPro Coding is not installed like the normal Programs. It is installed as a Aplikation App.
There are hidden direktorys some thing leike Windows/App/RoboProCoding/...
May be there is your lost direktory.

An other ting is, wehen you logt in Windows, not as an Admin or a User who has not read acsess to that.
Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 28 Aug 2023, 16:33
von fishfriend
Hallo...
OK, it is possible that the file is on the TXT 4.0 ?
So, i know it from the AI-Sortingline that the LOG-File is there.
Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 30 Aug 2023, 12:30
von zhengtzer
Hihi,


just checked in windows app, folder and subfolder all, not there
beemo.png
beemo.png (23.87 KiB) 8318 mal betrachtet
search on txt4.0, not there either

from your experience, is this how ft work?
let us user self study to dig out product info?


tyty

Re: How to save an input value to a file?

Verfasst: 30 Aug 2023, 16:29
von fishfriend
Hallo...
IF you use wlan or USB (or BT).
Check the IP Adress on the TXT 4.0. Linke: 192.168.2.101
Info/WLan
Take a browser, insert the IP Ardess.
Then you must insert: ft
and in the second Line: fischertechnik

And now go to TXT 4.0 folder.
Ther are a direktory(s) where the file (may be) is.
The upper dir (I think that ist the /ft/GUI)

Cause the Python Program runs on the TXT 4.0.
The TXT 4.0 has no permission to write a file on the PC.
Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 31 Aug 2023, 12:41
von zhengtzer
Hi


thanks, i learn something from you today :D
dont know ft txt4.0 can be access in such as way
ft_web.png
ft_web.png (76.3 KiB) 8254 mal betrachtet
i search through all folder, no file to be seen
ft_gui.png
ft_gui.png (98.4 KiB) 8254 mal betrachtet
i try manual key in ft/gui, not here
ft_web_gui.png
ft_web_gui.png (91.91 KiB) 8254 mal betrachtet

**studying the new AI sorting line, found out "ui" path, share with you
sortingLine.png
sortingLine.png (518.24 KiB) 8211 mal betrachtet
below is usual txt4.0 controller, will show node-red dashboard @_@
usual_txt40.png
usual_txt40.png (41.92 KiB) 8210 mal betrachtet


thanks
Jonathan

Re: How to save an input value to a file?

Verfasst: 31 Aug 2023, 16:27
von fishfriend
Hallo...
The AI Program stored two Files.
1. A log.txt File and
2. last-image.png picture.
If you look in the AI Program.
The "logging" is with
import logging
logging.basicConfig(level=logging.ERROR, format="%(asctime)s %(levelname)-10s %(funcName)3s %(message)s #%(filename)3s:%(lineno)d")
May be you can wirte other things in the file.

But there must be a way without the logging.
I will search about it, but it take some time in the moment.

There a saveral ways, to connect the PC with the TXT 4.0 . SSH, Node Red, MQTT ...
Mit freundlichen Grüßen
Holger

Re: How to save an input value to a file?

Verfasst: 19 Nov 2023, 16:37
von Techum
zhengtzer hat geschrieben:
22 Aug 2023, 19:01
HiHi!!!

[Question 1]
i want to write the word "close" into file everytime i pressed a button
i want to know how to write value into a local file
[Question 2]
if doesn't change the file path, where exactly will the file been saved?
HI Jonathan, check here:
viewtopic.php?f=8&t=7482&p=63902#p63902
Techum