You can use the Forena module. Here is a quote from that page:
... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.
Here is another quote from Reasons for considering Forena, related to the "CSV" in the question here:
Reports created by Forena ... can be saved (exported) as PDF documents with embedded graphs. Other supported formats for saving a report are CSV, XLS, DOC, HTML, etc.
So if you'd install Forena in your "old" site, then these are the steps for creating such CSV files are:
- a custom SQL query (where you have the full power of SQL at your fingertips, and various extra features related to it provided by Forena, such as using report parameters, conditional SQL, etc).
- a custom report (either by an admin, or by just any regular user who is either familiar with creating what is called 'FRX files', or otherwise using the WYSIWYG report editor).
- saving the report in (eg) CSV format, using one of the typical hyperlinks to do so in a report.
These steps do not require any PHP coding.
Bonus: instead of CSV format, you also have an option to format it as either XML or JSON. For more details on that, refer to "How to add a link to the CSV download to my module page, for a report created with Forena?".
Alternative: not sure if it would fit your requirements, but you could also use the Feeds integration of Forena. In this case you'd install Forena in your new site, and use Forena to enable Feeds to just go get your data in your old site. Checkout the video tutorial about this topic (specific to this Feeds integration).
For an online demo (prior to installing/testing Forena), checkout these links:
Disclosure: I'm a co-maintainer (not owner ...) of this module,
I hope this does not violate the site's policy on self-promotion.