Re: [sqlite] read full txt file in one record
On Wed, 6 Apr 2011 00:08:47 +0300, Gert Van Asschewrote: >Dear all, > >what would be the best way to read a full txt file into one record? >Now, when I use > .import FILE TABLE >I have every line on a record. > >I need all lines of one file on one record. >The next record I need to fill with all lines of another file. Here's a oneliner (line wrapped by mail) that stores a series of text files in BLOBs, one file per row. It works for binary files as well. d=test.db3 ; echo "CREATE TABLE Files (name TEXT PRIMARY KEY,contents BLOB);" | sqlite3 $d ; for f in yourfiles* ; do echo "INSERT INTO Files (name,contents) VALUES ('$f',X'$(od -v -A n -t x1 $f|tr -d '\r\n\t ')');" | sqlite3 $d ; done It might not be what you're looking for. -- ( Kees Nuyt ) c[_] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] read full txt file in one record
>3. edit the database file with a hex editor, replacing "~~" with "0D 0A". That seems pretty dangerous! Rather update the table using the standard replace() function. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] read full txt file in one record
From: Gert Van Assche <ger...@datamundi.be> To: sqlite-users@sqlite.org Sent: Wed, April 6, 2011 12:08:47 AM Subject: [sqlite] read full txt file in one record >Dear all, >what would be the best way to read a full txt file into one record? Until the experts reply to this, I'll try my cumbersome solution: (I am no expert, but I tried to find a walk around which worked for me) 1. In every text file: replace (with a hex editor) the hex sequence "0D 0A" (this is the CR + LF code ) with any other tow ASCII chars that you know for sure they won't appear in the text files (i.e. "~~"). 2. .import FILE TABLE 3. edit the database file with a hex editor, replacing "~~" with "0D 0A". To test it: SELECT rowid, your_text_data_column FROM your_table; Hopes it helps .. somehow. >Now, when I use .import FILE TABLE >I have every line on a record. >I need all lines of one file on one record. >The next record I need to fill with all lines of another file. >thanks for your advise. >Gert ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] read full txt file in one record
Dear all, what would be the best way to read a full txt file into one record? Now, when I use .import FILE TABLE I have every line on a record. I need all lines of one file on one record. The next record I need to fill with all lines of another file. thanks for your advise. Gert ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users