Fixing exporting and clearing my TinyDB data

Hi :slight_smile:
After fixing the storing and displaying of TinyDB data in my topic: How can I create data storage using clock component and display it in a table using calendar?, I have to fix the exporting and clearing data.

Having already seen various ways of exporting, I think the simplest way will be to save a csv file and then send it by email. So the file will be created when the user clicks the "Export Day Data" button or "Export DataBase", and once the user has emailed the file, he will import it on his own into the table view application of his choice.

I would start by saving the file that contains all the data collected (all the tags).
I tried this combination of blocks, but it doesn't work:

How can I save the csv file and send it?

Something like this?

I did it:

...but the response is: "...file could not be found..." :slight_smile:

Double check the circled block.

Should be list TO CSV table.

Also, this particular app stores different days' readings in different TinyDB NamSpaces, by day (YYYYMMDD?) , so the NameSpace needs to be set before getting the Tag List and doing the extraction.

Yes, sorry :frowning:

Thanks
...first I have to solve the problem of my phone failing server connection for outgoing mail, as I normally don't use this android phone

ok,
...so when I use the block: "list from csv table ... text" I get a file attached to the mail.
Instead, when I use the block: "list to csv table ... list" no file is attached to the mail
What is the problem?

Really? It should generate a runtime error....

I checked once more and that's it.
With these blocks I get the attached file (obviously the file is empty):

and with these blocks I don't get any attached files:

What does your taglist look like ?

Are there any values in any of the tags?

I am surprised you got any data at all.

Today I got the error :slight_smile:

Schermata 2022-09-08 alle 09.11.12

There are several tags with data on my phone; day readings of three months.
For example this is one Namespace (one day reading data) with two tags (two reading sessions data):
Schermata 2022-09-08 alle 10.29.31

Today, with the "...list to table..." block I got my file, but it contains only data of the selected day in my table. That's why yesterday the file was empty.

I should get all the existing tags when clicking "Export Database". How?

I also added the Namespace settings and it seems it makes no difference. Should I keep it or is it enough just "get tags" like above?
Anyway, this or previous combination is perfect for exporting the day data by clicking "Export Day Data" button.
For this option I added a second File component "File2". Is it ok?
And I added also the data title; the date of the exported day (I would need it also when exporting the whole database).

So this is how it appears in Excel:
Schermata 2022-09-08 alle 11.13.22

This is in Word:
Schermata 2022-09-08 alle 11.14.22

This is in Mail Preview:
Schermata 2022-09-08 alle 11.13.47

...instead, it should look like this:

Schermata 2022-09-08 alle 11.23.58

I would have preferred the date pattern as I set it in my blocks, but Excel automatically sets it short.

So all of this has to be fixed, how?
Nadi_11.aia (791.8 KB)

You have made the beginner blunder of over-formatting the internal storage of your data to match how you want it to appear externally in the phone display.

Internal data formats like lists and Instants preserve data values independently of other data values that you might want to mix with them at display times.

The price for the early blunder is to try to recover independent data from each cell of your stored data, usually by splitting each cell at \n, cell by cell.

The data I archived is not real, it was just for testing, so I don't care about recovering the data.
I would like to understand how to fix the blocks so that from now on the data storage can be exported.
So how can I get all tags?

If you want csv format exports, you can't have embedded \n in any cell.
You might try replacing them with '|', cell by cell, before export.

Decide on a date range for you export, using 2 date pickers.
Convert the 2 Instants (from, to) to milliseconds, and loop for each milliseconds from milliseconds1 to milliseconds2 by (number of milliseconds in a day).
In each loop, convert the current milliseconds back to an Instant and format it as a NameSpace value (YYYYMMDD).
Append the exported csv for that TinyDB NameSpace to your out file, day by day.

The "\n" separator in the cell is ok. The wrong display not separating items into columns was just a problem with my Excel.
I opened the file in Google Sheets and it's perfect.

However I think it is useful to save a second file by replacing the column separators from "," to ";" (this works fine) so users can open the file in Excel as well.

But the Sharing sends two separate emails.
How can I send two files in the same email?

I tried to understand it but I can't.
Can you show the blocks, please?

Sorry, I have not used email or the sharing component yet.

My email FAQ:

Can you do the first step, adding a From Date and To Date Date picker to your export request button in the Designer?

Is this what you asked?

I set it on invisible, ...I hope your solution does not involve entering dates by the user.
Nadi_12.aia (792.5 KB)

Do you want to include multiple dates' worth of reading in individual export files?