SQLite Forum

Suggestion to support gzipped text in vsv extension
Hello Keith,

Since SQLite has added zlib to its usual dependencies, I thought worth supporting gzipped text in [your vsv extension](http://www.dessus.com/files/vsv.c).

It ended up being very simple:

--- ../KeithMedcalf/vsv.c       2021-07-07 17:44:36.000000000 +0200
+++ ./vsv.c     2021-09-19 20:13:32.281978471 +0200
@@ -198,6 +198,9 @@
 **    CREATE VIRTUAL TABLE temp.csv USING csv(filename=FILENAME);
 **    SELECT * FROM csv;
+** The file content can be plain text, or text compressed with gzip (if this
+** code was compiled with "-DSQLITE_HAVE_ZLIB -lz").
 ** The columns are named "c1", "c2", "c3", ... by default.  Or the
 ** application can define its own CREATE TABLE statement using the
 ** schema= parameter, like this:
@@ -226,6 +229,15 @@
 #include <stdio.h>
 #include <math.h>

+#include <zlib.h>
+#define fopen  gzopen
+#define fclose gzclose
+#define fread  gzfread
+#define fseek  gzseek
+#define ftell  gztell

@@ -257,7 +269,11 @@
 typedef struct VsvReader VsvReader;
 struct VsvReader
+    gzFile in;             /* Read the VSV text from this compressed input stream */
     FILE *in;              /* Read the VSV text from this input stream */
     char *z;               /* Accumulated text for a field */
     int n;                 /* Number of bytes in z */
     int nAlloc;            /* Space allocated for z[] */

Would you please consider incorporating this patch (or variations of it) into your code?
I of course give this patch a public domain license.

Thanks in advance,