Exporting query results for use in a spreadsheet
Save the rows a query returns as a CSV file with a header row of field names. Import it into a spreadsheet, then check the columns came across correctly before further analysis.
Understanding Exporting query results for use in a spreadsheet in VCE Data Analytics U3O1
What it does: One line of a CSV file is one record. Commas separate the field values, so 'Ava,120' is a student's name and points. ISNUMBER returns TRUE if the imported points value is stored as a number. This checks the column came across correctly before analysis. The header row holds the field names, which become the column headings in the spreadsheet. The exported file is a copy of the query results. Analysing it in a spreadsheet does not change the database. Each field in the query result becomes one column, so three fields give three columns. Check the headings, the number of columns and the data types before you start calculating or charting.
Common mistakes: The export must be in CSV format so a spreadsheet can import it. The line should be .mode csv. .mode html would write HTML tags instead of comma-separated values. .output sends the query results into a file. .read tries to run a file as commands, so no CSV would be created. It should be .output stock.csv.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 17–49) and word search (Modules 17–91).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
Export query results as CSVFill in the Blanks
Spot the Error
Student with a class code? Join your class →