Lesson 9 of 10 · Lab
Export results to CSV and make a first chart
Output writes a table to a file. Vista Source publishes a table to Vista, Oplema's browser app for dashboards, where dashboards are built. Give both the same table, and the file and the chart can't disagree.
A flow's result stays in the flow until you send it somewhere. Marit wants a file for the accountant and one picture for herself.
This live flow in Strata, Oplema's browser app for data prep, holds the week's 93 Harbour hires at fictional Kramerica Bikes, your Formula and the summary by bike code from the last lesson. It runs in your browser, so Output downloads the file rather than saving it to a folder.
Output and Vista Source both need Summarize's table. Do you need a second Summarize?
No. One output can feed both blocks, as it fed Count Dataset in the last lesson, so the file and the chart come from the same four rows.
Download the file and publish the table
- Summarize opens first, with the week's four rows by bike code.
- In the palette, select IO and drag Output to the right of Summarize. It wires itself to Summarize.
- If Output is set to Local folder, this page can't save to it. Select Output and change Local folder to Download.
- If Output shows 93 rows, it's wired to Formula: delete that wire and drag from Summarize's right dot to Output's left dot.
- Select Output, select the Filename field, select all (Ctrl+A or Cmd+A) and type
harbour-week. - Select Run local. Your browser downloads the file. If nothing downloads, Output has no wire: drag from Summarize's right dot to Output's left dot.
- Publish the same table to Vista: drag Vista Source from IO below Output and wire Summarize to it.
- Select Vista Source, select the Display name field, select all (Ctrl+A or Cmd+A) and type
harbour_week.
Swipe sideways to see the canvas, or open this page on a larger screen to work with it.
In an expression, press Esc to apply it and move on (press it twice if a suggestion list is open).
What the file should hold
Four rows, one per bike code, with hires, bikes, gross and net: the same as Summarize's preview. Open it in a text editor rather than a spreadsheet, so nothing reformats the amounts. The file holds dated hires only, so report the 3 undated hires, worth €93.00 gross, beside it.
The chart and the file agree
Here the week's net by bike code is already charted in Vista, as your harbour_week table would be. The bars add up to €3,274.80, the figure above them, and the tallest is CTY, labeled €1,976: bar labels drop trailing zeros.
Open this page on a larger screen to edit this dashboard.
Check a chart the way you check a table: against a figure you've proven. The CTY bar should match CTY's net in your downloaded file, 1976.00. A chart drawn from another table, or from a filtered one, looks just as convincing.
See the Output and Vista Source references. For later: How to choose the right chart explains why bars suit this one.
Common export mistakes
- Opening the CSV in a spreadsheet and saving it. Saving can rewrite amounts and dates to your computer's settings. Send the file as the flow wrote it.
- Charting from a different table. Then the chart and the file can disagree. Branch both from one block.
- Charting gross when the report says net. Check which column the chart adds up. Its total should match the file's.
COPY and Save As in SQL and Excel
COPY (SELECT bike_code, count(*) AS hires, sum(net_eur) AS net
FROM week GROUP BY bike_code)
TO 'harbour-week.csv' (HEADER);DuckDB's COPY ... TO writes a query's result to a file, as Output does. In Excel, File > Save As > CSV writes the sheet with your computer's separators, which is how a European laptop ends up writing semicolons.