On Mon, 2 Mar 2015 09:07:55 +0000 Hick Gunter <hick at scigames.at> wrote:
> We do that here. Works well most of the time, but fails miserably if > the first 10 columns are not representative of the data. By "that", I take you mean sampling 10 rows to determine the appropriate widths. > Also requires each and every query to be run twice. Not good for > queries that require sorting of the result set No need to run the query twice. Just buffer the first 10 lines, compute widths, print them, and continue. My .autowidth suggestion is just a convenience. More important to me is that 1,000,000,000 doesn't appear as 10,000,000 just because the width is set to 8. --jkl > > -----Urspr?ngliche Nachricht----- > Von: James K. Lowden [mailto:jklowden at schemamania.org] > Gesendet: Montag, 02. M?rz 2015 05:28 > An: sqlite-users at mailinglists.sqlite.org > Betreff: Re: [sqlite] Characters corrupt after importing a CSV file > > On Thu, 26 Feb 2015 10:58:30 +0000 > Adam Podstawczy?ski <adam at podstawczynski.com> wrote: > > > While this solves the issue for me, I still believe this behavior is > > confusing ? truncated characters should be handled more gracefully. > > To your point, I think the column and column-width features of the > shell could benefit from some re-thinking. > > My ~/.sqliterc includes these lines: > > .mode column > .header ON > > and truncated strings and numbers are a source of confusion and error > even though I know how they work. > > I wish that by default column formatting would be "soft" in the sense > that printf(1) and printf(3) define: digits to the left of the > decimal are never truncated, and strings are not truncated unless > explicitly requested: > > $ printf '%5.4f\n' 123456789.123456789 > 123456789.1235 > $ printf '%5.4s\n' 123456789.123456789 > 1234 > > This would make the output "snakey" on the screen sometimes, but > would never conceal important information. > > I would change the width specification to accept the width and > precision notation used by printf. The statement > > .width 8 > > would mean "set the minimum column width to 8", whereas > > .width 8.8 > > would mean "set the minumum width to 8, minimum precision to 8, and > truncate strings to 8". I wouldn't worry about columns that mix > strings and numbers; funny-looking strings in that case should be > expected. And, besides, don't do that. > > It would also be nice to have a mode ".autowidth" that set column > widths based on, say, the first 10 lines (and, preferably, their > labels) in a manner similar to column(1). Provided it never > truncated anything, I would use that more often than an > improved .width. > > Thoughts? > > --jkl > > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > ___________________________________________ > Gunter Hick > Software Engineer > Scientific Games International GmbH > FN 157284 a, HG Wien > Klitschgasse 2-4, A-1130 Vienna, Austria > Tel: +43 1 80100 0 > E-Mail: hick at scigames.at > > This communication (including any attachments) is intended for the > use of the intended recipient(s) only and may contain information > that is confidential, privileged or legally protected. Any > unauthorized use or dissemination of this communication is strictly > prohibited. If you have received this communication in error, please > immediately notify the sender by return e-mail message and delete all > copies of the original communication. Thank you for your cooperation. > > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users