We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone
In my program im using several variables and I want to save them to txt file or excel file. After that I will make some graphs with them in other program. http://scr.hu/5o3i/35y8h here is my variables. I know how to show them in console by println but idk how to save them. Saw saveTable and saveStrings but i dont know how to use them to my program.
thx for help
Answers
https://processing.org/reference/saveStrings_.html
https://processing.org/reference/saveTable_.html
Saw this but ive got float values and i think i cant save it by strings, am I right ?
@merbb --
Well, a .txt or .csv file is string character data. So if you want to store floats in that format then you have to save them as strings at some point. However, Table will handle this for you.
Look at the Table reference page, which includes getFloat and setFloat methods:
Then try the example sketch for setFloat -- and try adapting the saveTable and loadTable example sketches from the reference to include a float column to see how this works.
There is one problem in my table. It saves data in file only in 1st row. Next are 0's. In console it saves every single one http://scr.hu/5o3i/b80nm but in file it's like here http://scr.hu/5o3i/uo5zk . Other question: why ive got xp, yp, zp in 1 column ? There are 3 columns in my sketch.
https://Processing.org/reference/Table_addRow_.html
@GoToLoop
http://scr.hu/5o3i/rnabp. This is how it works but its still bad i want sth like this http://scr.hu/5o3i/xewuu
In line 14-16 you're just adding a thousand empty rows to the table.
Sorry, but why did you post a non-compilable code anyways? :-@
I understand, I've just wanted to make more rows for xp,yp,zp. Still dont know how to save every single one 1 by 1 in table
@GoToLoop Its only few line from the whole code. I cant upload it because its about 600 lines. Need just some answers and i will do it.
It's only saving the last position of robot but i want to save every position to make some graphs
Move lines 7 to 11 into your for loop in line 15 and it should work. Here is another approach https://forum.processing.org/two/discussion/comment/72439/#Comment_72439 where it shows how to access your rows that you just created suing your current code.
Kf
Unfortunately it doesn't work. http://scr.hu/5o3i/ot9tz
Still you should try to post a runnable code to give some idea what's exactly about it.
The way it is now, it just sends the wrong signal, given it simply creates 1001 empty rows. :-@
It works like this:
I want to save every position of xp, yp, zp in a different rows.
Do u know what I need now ?
This code saves a fixed number of entries of mouseX and mouseY data.
Kf
Another way to save data. However it doesn't help in your case. Shown here just for demonstration:
Kf
Hell yeah @kfrajer TY very much, your answer is that I was looking for. Sorry for my English im speaking Polish normally
Oh, @kfrajer was much faster than moi! =P~
Anywayz, gonna post mine as well since it's still an alternative way on how to do the same stuff: :ar!
@GoToLoop
How would you modify your code to append data without reading the original file first, as I have seen in previous post? I am not sure if current Processing functions allow to do this. I have seen doing this using standard java output routines. Do you know a way of doing this?
Kf
You've said it yourself: "I am not sure if current Processing functions allow to do this.".
Unless the ".csv" becomes too huge, we shouldn't worry about its size.
Otherwise, we should even drop Table and do everything in a boilerplate Java-ish way! :-SS