Exporting a CSV File

 

I wanted to give at least one example of an output that is not defined by the printed page and is not designed to be read by a human being.

So here, I’ll explain how to export information from your notes into a .csv file that can be read by and imported into most spreadsheet programs.

The process for making this .csv file are exactly the same as the process used to make a form letter, and what follows assume you are familiar with that post.

Writing the Sample

As with all the examples I’ve given, the starting point is a written example of the output I want Tinderbox to create. In this case though, what that written output should look like isn’t obvious. What I know is that when I import my book notes into Numbers, I want them to look like this:

 

To create that row in Numbers, I need to create a .csv file that the application can read. I’m not a computer scientist and don’t know from memory what that file looks like, so I google it and wind up on Wikipedia and learn that a .csv file:

  • is plaintext;
  • places each row of data on its own line; and
  • separates each column’s data by a comma (or a semi-colon).

I can do that.

So I write out my sample .csv row in a note and end up with this:

I don’t know if spaces after the commas are required or allowed, so I try without them. If they are required, I’ll edit the template later to add them.

According to Wikipedia, there are also nuances in the format: you can import column headers for example. If you need these, you can figure them out and adjust your sample to include them.

When you think you have everything right, cut-and-paste your sample into a text file and import it into your spreadsheet. If everything shows up how you want it, great. If not, fiddle with your sample until it does.

Creating the Template

With a working sample in hand, creating the template is easy. Just replace the specific data with the export code used in the other examples—^value()^ unless if it’s one of the exceptions—and you wind up with this:

Export: Copy-Paste

When I use .csv export (which I do pretty regularly), I never actually export the notes. I switch to preview, select and copy the preview text, and then paste it into a new .txt document. From there it’s ready to import into Numbers, Exel or whichever other spreadsheet you use. (For suggestions how how to easily import impromptu groups of notes into a spreadsheet, see this forum thread.)

The other export examples are here.