Re: [sqlite] how to write line feed "\n\r" when output a txt file

2012-05-15 Thread Jean-Denis MUYS

On 14 mai 2012, at 21:03, Kees Nuyt wrote:

> On Mon, 14 May 2012 05:41:08 +, YAN HONG YE 
> wrote:
> […]

> By the way, common lineendings are platform dependent

> MS Windows: \r\n  = 0x0D 0x0A = cr lf
> Unix/Linux: \n= 0x0A = lf
> Apple  Mac: \r= 0x0D = cr
> 

This is incorrect.

First off, Apple Mac is hardware, and as such, it doesn't use *any* line 
ending. It will use CR-LF (Windows) line endings by default if you install 
Windows, and LF (Unix) line endings by default if you install Unix or Linux - 
or Mac OS X which is Unix.

Apple's Operating System has been Mac OS X - certified Unix - for over a 
decade, and has been using LF line endings by default ever since. The Mac 
hasn't been using CR line endings for over 10 years.

10 years is a very long time in this industry. 

Jean-Denis

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] how to write line feed "\n\r" when output a txt file

2012-05-14 Thread Black, Michael (IS)
Under windows:

SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t(a,b);
sqlite> insert into t values(1,2);
sqlite> insert into t values(3,4);
sqlite> .output akk.txt
sqlite> select * from t;
sqlite> .output stdout
sqlite> .quit

od -x akk.txt
000 7c31 0a32 7c33 0a34
010

LF only -- no CR.

So the output won't be happy under notepad.  Wordpad would work fine though on 
the file.  After which you save it from Wordpad and you'll have the CR/LF.
od -x akk.txt
000 7c31 0d32 330a 347c 0a0d


Michael D. Black
Senior Scientist
Advanced Analytics Directorate
Advanced GEOINT Solutions Operating Unit
Northrop Grumman Information Systems



From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Kees Nuyt [k.n...@zonnet.nl]
Sent: Monday, May 14, 2012 2:03 PM
To: sqlite-users@sqlite.org
Subject: EXT :Re: [sqlite] how to write line feed "\n\r" when output a txt file


On Mon, 14 May 2012 05:41:08 +, YAN HONG YE <yanhong...@mpsa.com>
wrote:

>when I use :
>
>.output akk.txt
>select * from dhq where qph>0;
>.output stdout
>
> command to write a txt file,I found no "\n\r" in the each line,

Are you sure?

By the way, common lineendings are platform dependent

MS Windows: \r\n  = 0x0D 0x0A = cr lf
Unix/Linux: \n= 0x0A = lf
Apple  Mac: \r= 0x0D = cr

As far as i know, using
\n\r  = 0x0A 0x0D = lf cr
is very very rare. In fact I only saw it on the console interface of a
DATUS portselector, back in the 1980s.

> how to write "\n\r" each line in the output txt file?

Pipe it through awk, for example (Unix/Linux):

printf "select * from dhq where qph>0;\n" \
| sqlite3 your.db \
| awk '{printf "%s\r\n",$0}' \
>akk.txt

In awk on MS Windows, "\n" will render "\r\n", except when BINMODE is
used.

Many programs are able to cope with several different line endings, but
indeed notepad insists on \r\n.

Hope this helps.

--
Regards,

Kees Nuyt

___
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


Re: [sqlite] how to write line feed "\n\r" when output a txt file

2012-05-14 Thread Kees Nuyt
On Mon, 14 May 2012 05:41:08 +, YAN HONG YE 
wrote:

>when I use :
>
>.output akk.txt
>select * from dhq where qph>0;
>.output stdout
>
> command to write a txt file,I found no "\n\r" in the each line,

Are you sure?

By the way, common lineendings are platform dependent

MS Windows: \r\n  = 0x0D 0x0A = cr lf
Unix/Linux: \n= 0x0A = lf
Apple  Mac: \r= 0x0D = cr

As far as i know, using 
\n\r  = 0x0A 0x0D = lf cr
is very very rare. In fact I only saw it on the console interface of a
DATUS portselector, back in the 1980s.

> how to write "\n\r" each line in the output txt file? 

Pipe it through awk, for example (Unix/Linux):

printf "select * from dhq where qph>0;\n" \
| sqlite3 your.db \
| awk '{printf "%s\r\n",$0}' \
>akk.txt

In awk on MS Windows, "\n" will render "\r\n", except when BINMODE is
used.

Many programs are able to cope with several different line endings, but
indeed notepad insists on \r\n.

Hope this helps.

-- 
Regards,

Kees Nuyt

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users