Alejandro wrote:At the end I will need to export a 2D matrix with all these zero values to perform my analyses.
Here is how you produce the 2-dimensional table from your database. I reference the following attachment, where I show three tables from a database, the result of a query from the database, a pivot table, and the final result. Though some of the data is actually in a database, I show it all in a spreadsheet so I can make one attachment. These are the sheets:
• Table.Pubs: A copy of the
pubs table from the earlier database to show you the data I used
• Table.Series: A copy of the
species table from the earlier database to show you the data I used
* Table.PubsAndSpecies: A copy of the
pubsXspecies table from the earlier database to show you the data I used, modified to add an Abundance field
• Query.Lookup: A
database query which uses a
JOIN of the three prior
database tables to gather the needed information in one collection
• PivotTable: A pivot table created in
Calc with the Query.Lookup sheet cells as its source
• Zeros: A simple sheet created from the pivot table using the N() function to turn empty cells into zeros for export
I would build the query in the database, access it in Calc with View → Data Sources, then drag the query result into the Query.Lookup sheet.
Calc Guide Chapter 10 - Linking Calc Data
The pivot table takes me less than a minute to create. If you have not used one before, you will want to read the guide. You can see how my pivot table was configured by clicking any cell in it and using Data → Pivot Table → Create.
Calc Guide Chapter 8 - Using a Pivot Table (formerly called Data Pilot)
Your spreadsheet will have only the query data, the pivot table, and the Zeros sheet since the other data is in your database.
After you have saved the 3-sheet spreadsheet as an ODS file, you can export the Zeros sheet with its 2-dimensional table to CSV with File → Save As →
(scroll down for) Text CSV, then use the CSV for your further "analysis". This small example uses only seven species. If you have a thousand, your pivot table will be much wider to show them all.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).