BentoUsers

Fixing CSV Exports

The AppleScript that came with this post is no longer available. The fix below works without it.

A home desk with an Apple Cinema Display, an aluminium keyboard and a MacBook, Mac OS X dock on screen
A Mac desk of the Bento years. Photo: David Wellbeloved (CC BY 2.0).

Bento 1.0v2 could write broken CSV files when a field contained double quotes.

The fault

CSV allows each field to be wrapped in double quotes, and any double quote inside a field is written twice so it is not mistaken for the end of the field. Bento did write the doubled quotes, but for each one it moved the closing quote one character to the left. Programs reading the file then split fields in the wrong places.

The workaround at the time

We published an AppleScript, Double Quote Fixer, that re-read the exported file and put the closing quotes back. It needed an extra calculation field holding a single character, such as a pipe, to mark the end of each record, and it only coped with one field containing quotes.

If you hit this now

The script is no longer available, and later Bento versions handled quotes correctly. If an export from an old library looks scrambled in Numbers or another app:

Importing the file into a spreadsheet first, rather than straight into a database, makes misaligned columns easy to spot.

The Bento years in pictures

Photos: goblinbox (CC BY 2.0), David Wellbeloved (CC BY 2.0), Uadro (CC BY-SA 4.0) and Martin Pettitt (CC BY 2.0), via Openverse and Wikimedia Commons.