Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Add the ability to provide a list of files to read_csv #8977

Merged
merged 14 commits into from
Oct 6, 2023

Conversation

Tishj
Copy link
Contributor

@Tishj Tishj commented Sep 18, 2023

This PR fixes #8822

We now accept things like:

import duckdb
from io import StringIO

con = duckdb.connect()
file1 = StringIO('one,two,three,four\n1,2,3,4\n1,2,3,4\n1,2,3,4')
file2 = StringIO('one,two,three,four\n5,6,7,8\n5,6,7,8\n5,6,7,8')
file3 = StringIO('one,two,three,four\n9,10,11,12\n9,10,11,12\n9,10,11,12')
files = [file1, file2, file3]
rel = con.read_csv(files)
res = rel.fetchall()
assert res == [
	(1, 2, 3, 4),
	(1, 2, 3, 4),
	(1, 2, 3, 4),
	(5, 6, 7, 8),
	(5, 6, 7, 8),
	(5, 6, 7, 8),
	(9, 10, 11, 12),
	(9, 10, 11, 12),
	(9, 10, 11, 12),
]

@github-actions github-actions bot marked this pull request as draft September 18, 2023 11:21
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Looks good - some minor comments:

src/main/relation/read_csv_relation.cpp Outdated Show resolved Hide resolved
src/main/connection.cpp Outdated Show resolved Hide resolved
tools/pythonpkg/src/include/duckdb_python/path_like.hpp Outdated Show resolved Hide resolved
tools/pythonpkg/src/path_like.cpp Outdated Show resolved Hide resolved
@Mytherin Mytherin marked this pull request as ready for review September 21, 2023 08:34
@Mytherin
Copy link
Collaborator

Looks like the CI is actually broken here - could you have a look?

…calls the const string& overload instead of the vector<string>& overload? wild
@github-actions github-actions bot marked this pull request as draft September 21, 2023 19:28
@Tishj Tishj marked this pull request as ready for review September 21, 2023 19:29
@github-actions github-actions bot marked this pull request as draft September 25, 2023 08:10
@Tishj Tishj marked this pull request as ready for review October 2, 2023 10:24
@Tishj Tishj requested a review from Mytherin October 5, 2023 07:41
@Mytherin Mytherin changed the base branch from main to feature October 6, 2023 11:44
@Mytherin Mytherin merged commit bb36133 into duckdb:feature Oct 6, 2023
@Mytherin
Copy link
Collaborator

Mytherin commented Oct 6, 2023

Thanks!

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 11, 2023
Merge pull request duckdb/duckdb#9164 from Mause/feature/jdbc-uuid-param
Merge pull request duckdb/duckdb#9185 from pdet/adbc_07
Merge pull request duckdb/duckdb#9126 from Maxxen/parquet-kv-metadata
Merge pull request duckdb/duckdb#9123 from lnkuiper/parquet_schema
Merge pull request duckdb/duckdb#9086 from lnkuiper/json_inconsistent_structure
Merge pull request duckdb/duckdb#8977 from Tishj/python_readcsv_multi_v2
Merge pull request duckdb/duckdb#9279 from hawkfish/nsdate-cast
Merge pull request duckdb/duckdb#8851 from taniabogatsch/binary_lambdas
Merge pull request duckdb/duckdb#8983 from Maxxen/types/fixedsizelist
Merge pull request duckdb/duckdb#9318 from Maxxen/fix-unused
Merge pull request duckdb/duckdb#9220 from hawkfish/exclude
Merge pull request duckdb/duckdb#9230 from Maxxen/json-plan-serialization
Merge pull request duckdb/duckdb#9011 from Tmonster/add_create_statement_support_to_fuzzer
Merge pull request duckdb/duckdb#9400 from Maxxen/array-fixes
Merge pull request duckdb/duckdb#8741 from Tishj/python_import_cache_upgrade
Merge fixes
Merge pull request duckdb/duckdb#9395 from taniabogatsch/lambda-performance
Merge pull request duckdb/duckdb#9427 from Tishj/python_table_support_replacement_scan
Merge pull request duckdb/duckdb#9516 from carlopi/fixformat
Merge pull request duckdb/duckdb#9485 from Maxxen/fix-parquet-serialization
Merge pull request duckdb/duckdb#9388 from chrisiou/issue217
Merge pull request duckdb/duckdb#9565 from Maxxen/fix-array-vector-sizes
Merge pull request duckdb/duckdb#9583 from carlopi/feature
Merge pull request duckdb/duckdb#8907 from cryoEncryp/new-list-functions
Merge pull request duckdb/duckdb#8642 from Virgiel/capi-streaming-arrow
Merge pull request duckdb/duckdb#8658 from Tishj/pytype_optional
Merge pull request duckdb/duckdb#9040 from Light-City/feature/set_mg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[python] read_csv should accept iterable of filenames
2 participants