On 9/14/15, Sylvain Pointeau <sylvain.pointeau at gmail.com> wrote: > Hello, > > I think I have read on this mailing list that sqlite now has functions able > to return rows. (but cannot find it anymore)
https://www.sqlite.org/draft/vtab.html#tabfunc2 > > I am interested about this new functionality. Would it be possible to see a > very basic sample of it? > > Do you think we can implement a kind of CSV reader with this new function? > kind of: select * from CSVRead('/path/to/my/file.csv') > No. The table-valued function needs to return a predefined number of columns, but a CSV file can have a varying number of columns. To do this, you'd have to create a virtual table that actually gets instantiated per CSV file: CREATE VIRTUAL TABLE temp.file1 USING csvFileReader('/path/to/my/file.csv'); SELECT * FROM file1; DROP TABLE file1; In the above, the xCreate method of the virtual table implementation could peek at the CSV file to see how many columns it has before declaring how many rows it intends to return. Which is what you need. -- D. Richard Hipp drh at sqlite.org