On 1/17/18, 11:07 AM, "sqlite-users on behalf of Jens Alfke" 
<sqlite-users-boun...@mailinglists.sqlite.org on behalf of j...@mooseyard.com> 
wrote:
> If I were tackling this, I’d look for an open-source CSV parser/generator 
> library. Once you have that, the part that reads/writes the rows to the 
> database is pretty simple.

If they’re reading tab separated files, I wouldn’t use CSV code... there’s a 
lot of complexity in CSV readers that are unnecessary for TSV because it 
doesn’t support or require quoting of embedded separators.

Just something like

char *s, *cols[MAXLINE], line[MAXLINE];
int col;
while(fgets(line, MAXLINE, fp)) {
        s = line;
        col = 0;
        while(cols[col] = s, s = strchr(s, ‘\t’)) {
                *s++ = ‘\0’;
                col++;
        }
        if(s = strchr(cols[col], ‘\n’)) *s = ‘\0’;
        // bind cols[...] to prepared statement
        // step prepared statement
}



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to