Save list as csv and load it back

Hallo Xojo community,

I’m a new member. I beginn to learn with the ToDo listbox tutorial. At the end I added a “SAVE” button but don’t have any knowledge to write the appropriate code to save the ToDo list, for example as csv-file, in a manner that I can later load the file, to add further tasks and save it one more time.

cheers
Vincenzo Luciano

Hello Vincenzo,
please take a look at these topics in the Xojo-Documentation(->Help ->Language Reference or F1 within Xojo):
textoutputstream
textinputstream
Everything you need is described there with examplecode (for listbox data there is a example at textinputstream) to start with.

Desktop, Web, List, iOS ?

Compare the code below * to the TextInputStream example I took it from:

Dim t As TextOutputStream Dim f As FolderItem f = GetSaveFolderItem("", "Save_As_Example.csv") If f <> Nil Then t = TextOutputStream.Create(f) t.WriteLine(LB.Cell(-1,-1)) t.Close End If

Nota: the code above do not makes reliable backup file (in one test, it store everything from a certain Row until the end of the Listbox into only one Row instead of 20/280 Rows.

But this is an example.

Nota:
LB is the reference of the ListBox.
The Column delimiter is the default value: a Tab.
If you want another delimiter, change it before saving it to disk.Same apply of you want to put all Cells contents between quotes.

And so on.

Load LibreOffice, create a Calc File, populate it and try to export it to csv to know how “the industry” proposes. :wink:

Now you have an example to works from (simplistic).

Did I told you that examples of csv files and question about csv exists in this forum ?

BTW: I took the example from the API 1 LR. Changes may happens with API 2.

Hallo Rolf, Danke.
Bonjour Emily, Merci.

I will try my best and post a feedback.

Pardon Emile, i wrote wrong your Name.

Hi Vincenzo,

This happens to me so often on those last years that I do not notice it ! :wink:

Don’t worry.