We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Saving Data for later use (xml)
Page Index Toggle Pages: 1
Saving Data for later use (xml?) (Read 1406 times)
Saving Data for later use (xml?)
Aug 17th, 2009, 6:06am
 
Using the SMSlib http://smslib.org/ i wanna write a programm receiving short messages. As the messages are received by the mobile phone they are passed to the processing sketch and deleted from the phone. So they are not stored in any way and are lost as soon as the sketch is closed. What i want and need is a good ways to store the messages with all of the informaton like date, number etc.
So that i can start the programm again and it takes, lets say the last 20 messages received and adds every new message to the programm as well...

My question is, what would be a good way to store this information? i dont have a lot of knowledge beside storing/reading some values in txt files and i guess there is maybe a better way in this case. Is XML useful here? should i go with mysql or is it to overpowered? Keeping it simple would be good. But I am not sure what the best way to go would be.

If it is XML, where is the Processing built in XML library enough or should i prefere proXML by textone?

Thx for the help guys!
Re: Saving Data for later use (xml?)
Reply #1 - Aug 17th, 2009, 6:43am
 
Basically, it depends on what you want to do with the data later...

If you need to process the data, XML is a good choice. DB is another choice, allowing fast and simple queries (all SMS sent at a given time period, for example). Simpler CSV can be enough if you just need to reload in a sketch or edit in a simple editor. You can even use alternative formats like Json or Yaml or even INI/properties...
Re: Saving Data for later use (xml?)
Reply #2 - Aug 17th, 2009, 7:13am
 
thanks PhiLho,
i guess for now, a simple CSV would be enough. cause all i need to store is number, date, and messagetext. and for now simple storing the messages would be enough. a DB would be good though for later use, to make it possible to create different kind of visualisations.

so is there any benefit from using XML instead of a simple CSV in my case? like saying, get only messages from day X or from Nr. 0123...?

Another question on how to structure the programm. Lets say i want to create an object for every message received. The best way would be creating objects in an arrayList by reading the already existing data from the CSV in the setup first? and then add another object everytime an SMS is received  during runtime and store the Data in the Object and writes them to the CSV when closing the sketch, or writing the data to the CSV when the object is created... Is there anything i should think of or have to take care of?

Thx you.
Re: Saving Data for later use (xml?)
Reply #3 - Aug 17th, 2009, 1:10pm
 
For your simple structure, CSV is enough, XML would just add complexity of treatment without obvious advantage.

If rate of SMS isn't too high (say one per second or less), it can be interesting to append the CSV lines to the file on each reception: opening, writing and closing the file shouldn't take much time. And thus no risk of loosing a SMS in case of sketch crash or something.
Re: Saving Data for later use (xml?)
Reply #4 - Aug 17th, 2009, 1:16pm
 
alright, thank you. I was just not sure what makes more sense, but you are right. in this case i wont lose any messages.
Re: Saving Data for later use (xml?)
Reply #5 - Jan 7th, 2010, 12:26pm
 
I am also interested in saving data for later use, but I have not figured out how create and later append a CSV file.  Any suggestions?  I'm not very fluent in the code, so I'm really just trying to learn how to do this (probably very basic) action.

Thanks!
Re: Saving Data for later use (xml?)
Reply #6 - Jan 8th, 2010, 2:03am
 
All right, you got your answer in Creating, Writing, and Appending Files thread...
You can use split() to process CSV.
Also search the forum, you are not the first with this need... Smiley
Page Index Toggle Pages: 1