Repository navigation
feat: Excel IO — from_excel/2 and to_excel/2 - #23
Merged
Merged
Conversation
Add from_excel/2 (read_xlsx with header/sheet/range/all_varchar opts) and to_excel/2 (COPY TO XLSX with header). Requires DuckDB 1.5+. from_excel defaults to header: true so column names are read from the first row. to_excel always writes headers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add from_excel/2 (read_xlsx) and to_excel/2 (COPY TO XLSX). Defaults to ignore_errors: true and empty_as_varchar: true for safe handling of messy spreadsheets where type inference from the first row would fail. Uses Keyword.validate! for option checking. Options: sheet, range, header (default true), all_varchar, ignore_errors (default true), empty_as_varchar (default true), stop_at_empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Excel (.xlsx) read and write support via DuckDB's
read_xlsxandCOPY TO XLSX.Usage
Safe defaults for messy spreadsheets
DuckDB infers Excel column types from the first data row only. A NULL or empty cell in row 1 causes the column to be inferred as DOUBLE, which fails when later rows contain strings. Two safety nets enabled by default:
ignore_errors: true— type-cast failures become NULL instead of raisingempty_as_varchar: true— empty/null cells infer as VARCHAR instead of DOUBLETogether these handle the most common "messy spreadsheet" scenarios. Users who want strict type checking can pass
ignore_errors: false, empty_as_varchar: false. Users who want full control useall_varchar: true.Uses
Keyword.validate!for option checking — typos likeheaders:instead ofheader:raise immediately.Test plan
Happy path (3):
all_varchar: trueHappy path — writing (3):
Sad path (2):
Adversarial (5):
ignore_errors(no crash)all_varchar: truepreserves all dataignore_errors: false+empty_as_varchar: falseraises on type mismatchScale (1):
🤖 Generated with Claude Code