Page 1 of 1

Export from Base query to text/csv file?

Posted: Mon Oct 12, 2009 4:45 am
by eepofthegra
Can't find an option for exporting from a Query directly to a text/csv file.

Do I first need to copy the query results to a Calc file?

Hoping for a direct path...thanks.

Re: Export from Base query to text/csv file?

Posted: Mon Oct 12, 2009 10:35 am
by Villeroy
Register your database, drag your query from the beamer's left pane into the sheet (F4, drag&drop).
Edit the resulting import range (Data>Define...[More...]) and set all the additional properties.
Apply the number formats you want to see in the csv.
Save as ods.
Save as csv with default settings (comma separated, displayed as shown) and close.

Next time after your database changed:
- Open the spreadsheet, confirm to refresh the import range (we stored only the link, not the data).
- Save as csv with default settings.

[Tutorial] Using registered datasources in Calc

##########
HSQLDB knows editable text tables which can be populated from a view rather than query.
http://user.services.openoffice.org/en/forum/viewtopic.php?f=83&t=23260

Re: Export from Base query to text/csv file?

Posted: Mon Oct 12, 2009 5:33 pm
by eepofthegra
It just had to be that easy didn't it. ha ha ha.

Thank you. Danke!

Re: Export from Base query to text/csv file?

Posted: Mon Oct 12, 2009 5:38 pm
by Sliderule
eepofthegra:

Assuming your database is from HSQL, the 'embedded' database, another option is a macro.

The link below, please see the LAST post by Sliderule ( yours truly ) includes a macro where you can include via passed parameters, OR, prompts:
  1. Table name, View name, OR Query name ( including queries with prompts )
  2. Output file name
  3. Header-Yes OR Header-No ( column names to be included in output file )
  4. Registered file name
If you use the macro, please be sure to change, at the beginning, YOUR DEFAULTS.

This macro can be run:
  1. From Calc ( with output to a file )
  2. From another macro
  3. From a form
  4. From the toolbar - Macro -> Run
http://www.oooforum.org/forum/viewtopic.phtml?t=86880

I hope this helps, please be sure to let me / us know. :super:

Sliderule

Thanks to add [Solved] in your first post Subject ( edit button top right ) if your issue has been fixed / resolved.

Re: Export from Base query to text/csv file?

Posted: Mon Oct 12, 2009 7:09 pm
by Villeroy
eepofthegra wrote:It just had to be that easy didn't it. ha ha ha.

Thank you. Danke!
Indeed, the spreadsheet formatting is an easy way to specify all the details of your prefered ouput format once.
And the best thing: It works with any input table, even with other spreadsheets when you want to configure a certain output format your csv.

All you have to do then is opening a your prepared spreadsheet, confirm the refresh and save as csv with default options.

HSQL's built-in text table support is just another way to configure the output options once. Then you can drag your view onto the linked text table in order to write the file with the configured text option.
How to use the HSQLDB: [Solved] SQL: from OOo Base to tab-delimited text