Simple Recordset Export routine

I have a Mac application with an SQlite DB. I would like a simple method to export a recordset to a file that can be read into excel. (e.g CSV)

I do not not have or want to pay for Plugins.

Thanks
Jim

You don’t need a plugin for this. Create a method that iterates your database, and for each record concatenate a string separated by commas. For text fields wrap them in quotes, numeric fields no quotes etc. Write the string to an open text file with the extension .csv.

Be advised this may not work for Excel without a few other things, if that’s your target. A few gotchas…

  • you’ll need to escape quotes within quoted fields
  • you’ll need to watch text field length – anything around 32768 (slightly shorter in my experience) will cause a line break and new record
  • Excel actually prefers TSV; you can do CSV as a file, but if you want to support clipboard transfer, it needs to be TSV (for simple copy/paste)
1 Like

Thanks
Will try the suggestions