Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWt7s-000787-KC for pgsql-general@arkaria.postgresql.org; Wed, 12 Dec 2018 01:15:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gWt7q-0000QR-RU for pgsql-general@arkaria.postgresql.org; Wed, 12 Dec 2018 01:15:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWt7p-0000Nn-He for pgsql-general@lists.postgresql.org; Wed, 12 Dec 2018 01:15:46 +0000 Received: from nh601-vm0.bullet.mail.ssk.yahoo.co.jp ([182.22.90.9]) by makus.postgresql.org with smtp (Exim 4.89) (envelope-from ) id 1gWt7f-00070A-8w for pgsql-general@lists.postgresql.org; Wed, 12 Dec 2018 01:15:40 +0000 Received: from [182.22.66.104] by nh601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 12 Dec 2018 01:15:30 -0000 Received: from [182.22.91.132] by t602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 12 Dec 2018 01:15:30 -0000 Received: from [127.0.0.1] by omp605.mail.ssk.yahoo.co.jp with NNFMP; 12 Dec 2018 01:15:30 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 872244.56308.bm@omp605.mail.ssk.yahoo.co.jp X-YMail-OSG: ZNtoY7QVM1k3bW311nmEHVnKaGB4ufF3cHpuGVtX1fZF0_78.HrGhFgahwn27hp 31p1TGc14Cq.tmhVMeFZS12UXoAo10L3R_iR7G1IyES.YYco0iW12SkG1oZWOlYIZRTMl_JbHGKe GG6uUKe9ObQesizFlIZpmDIm9RzVcskQzOQs97PTQRMWn_nvigDsQdUTsJ0axtBqwdB0yqOSUp3S lX.iEEjY1hXpuRVQt8FNb1gWNlVSte2gNlxwr5b.asSTzdQLM2YuM6D500qy3VVoJRz9LNchfc6b kh5MHJRnInWqJObajnRhMYehUT1ON5VBBbhsEqSGFvJ_FdlcoWT3yy842Ne7phLYjRVXRT7fe3s9 ksuxbcVksS108JVFhHlnyX8pVI3KBT5S2zv.dQge_YDaRfTw7m.UODA2ox13qrPfJQk8v.dM1QVT L4QR9tlvK__0bOqTx1wpv5zye6KBfIoTsW_afnBcUpMXfDq1tgVWa8r1Aubw1hdIXn2sv6pWTteG nA1bWTz7lYBT6eSHsfMMNehBb7mODdwHjLgy4UJChbjcwnO17coX8hxEdAFu3VGGAyriT8Uiy1IA Z2SrtqYpecR2yGVLd.JiVoX9N5iYnrm82s_gykgM- Received: from jws700002.mail.kks.yahoo.co.jp by sendmailws507.mail.kks.yahoo.co.jp; Wed, 12 Dec 2018 10:15:30 +0000; 1544577330.155 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1544577330; s=yj20110701; d=yahoo.co.jp; h=Date:From:Reply-To:To:Message-ID:In-Reply-To:References:Subject:MIME-Version:Content-Type; bh=mfwczNgfAtnyh4h4sfWAa9CaWEBxnjmGnVgMWYVeotA=; b=GvOAJkwMgSgWfJu7exRcxTlOrvHO19AJUzAs3S5PVVDHoc/Js0gVLiUr2jd0Bp9j HHGcAoEmC3zozx249e6L3a3jXK1S8zjykEvs5p2eWD1QeeG4iLmrWMtnNDb4OyAzOAK 2WShF+/8brLWS69PAMs5sSFm+FWq3gJr9LaemwUI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Date:From:Reply-To:Message-ID:In-Reply-To:References:MIME-Version:Content-Type; b=ejzTsgXj3FcwmB/M3r+vEywOj9WUSl3hXnGIhlJZdva/8zU67+ZtxlMGmjm05PM3 8SHn2Rul8VAfJSgg+nN+ud5Z2sqiruUjv+vaiiPGc9adSnUendGi7qEcwsUP/P8+ZQp JP2qlHWD3xdtlQDSNGVXciLfi1Kh4PpdIbmxVlTE=; X-yjpVirusScan: Scanned Date: Wed, 12 Dec 2018 10:15:29 +0900 (JST) From: Reply-To: To: Adrian Klaver , rob stone , "pgsql-general@lists.postgresql.org" Message-ID: <1481072721.666834.1544577329299.JavaMail.yahoo@mail.yahoo.co.jp> In-Reply-To: References: <1892755171.196556.1544154847195.JavaMail.yahoo.ref@mail.yahoo.co.jp> <1892755171.196556.1544154847195.JavaMail.yahoo@mail.yahoo.co.jp> <1c54581d-541d-10d9-138c-55b87ecded2c@aklaver.com> <5e4cd2243e4e89afdad1ab7fb503825084f771ab.camel@gmail.com> <1078893091.227120.1544171298546.JavaMail.yahoo@mail.yahoo.co.jp> <4969722f-8869-fa9b-d843-05bc863306f4@aklaver.com> <683172210.269176.1544202278516.JavaMail.yahoo@mail.yahoo.co.jp> Subject: Re: Importing tab delimited text file using phpPgAdmin 5.1 GUI MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_666833_1819731349.1544577329292" Content-Length: 31558 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_666833_1819731349.1544577329292 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To Adrian:Your question: "The original encoding was Win-10 (Japanese) corre= ct?"Let me answer this way:Yes, I created the file using used Win 10 (J)'s = Excel (2016).When I saved the file as tab delimited text, it seems it was s= aved as ANSI because when I opened it using notepad, I could see it was ANS= I.I then changed the encoding to UTF-8 using the notepad ....=C2=A0=C2=A0= =C2=A0 But=C2=A0I gave up on importing using the phpPgAdmin.=C2=A0Over the weekend= , I found a way using PHP. Here is a snippet:=C2=A0(1) reading file and creating a 2D array:$fileRead = =3D fopen($file, 'r');$row =3D 1;$twoDarray =3D array();while (($line =3D f= getcsv($fileRead, "\t")) !=3D=3D FALSE) {if($row =3D=3D 1){ $row++; continu= e; } //skip header =C2=A0 =C2=A0 $line =3D implode(" ",$line). "\n";=C2=A0 = =C2=A0=C2=A0$twoDarray[] =3D $line;}fclose($fileRead); (2)$con=3Dpg_connect("host=3D$host..."); if (!$con) { die("...");} if (pg_copy_from($con, $tableName, $twoDarray) !=3D=3D FALSE) { print "Suc= cess!";}else{ print "Failed!"; } pg_close($con); //------------------------------ Oh, yes, I had to convert the=C2=A0tab delimited text file to UTF-8 encodin= g. For this purpose the notepad was enough. Some version of Excel seem to offer the option to save file with UTF-8 enco= ding, but the one I am using does not have that option. Time to move ahead. Thanks! ----- Original Message ----- From: Adrian Klaver To: s400t@yahoo.co.jp; rob stone ; "pgsql-general@li= sts.postgresql.org" =20 Date: 2018/12/8, Sat 06:35 Subject: Re: Importing tab delimited text file using phpPgAdmin 5.1 GUI =20 On 12/7/18 9:04 AM, s400t@yahoo.co.jp wrote: > I didn't specify any schema, so it was created in public schema. > The error message also says "public"... > //------------------------------------------------------------------ > ERROR: column "=EF=BB=BFrec_id" of relation "spec" does not exist > LINE 1: INSERT INTO "public"."spec" ("=EF=BB=BFrec_id","title_c... > //------------------------------------------------------------------ >=20 > Output of the \d spec: >=20 >=20 >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Table= "public.spec" >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Column=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Type=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0| Modifiers > ----------------------------+-------------------------+----------- >=C2=A0 =C2=A0rec_id=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| character varying(32)=C2=A0 =C2=A0| not null >=C2=A0 =C2=A0title_category=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| character varying(255)=C2=A0 | >=C2=A0 =C2=A0doctype=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | character varying(255)=C2=A0 | >=C2=A0 =C2=A0... goes on like this for other columns. >=20 > What are you trying to see in the output of \d spec? My basic procedure in troubleshooting is starting from the known and=20 working out to the unknown. So my questions about the schema(s) and the=20 table definition where to establish a know starting point. Also a common=20 issue that hit this list are multiple versions(across schemas) of an=20 object in a database and code hitting the wrong version. One of the=20 signs of that being error messages of the form you got. >=20 > I don't understand what you mean by the import code is trying to insert= =20 > in to wrong version of the table. > I visually checked the left side "menu like" structure of the=20 > phpPgAdmin- there is no other table of that name. See above. >=20 > You mentioned that quoted identifiers are not the issue. > This prompted me to test the process in a table with a few columns and=20 > ascii characters. > Immediately it was clear that quoted identifiers were not to blame. >=20 > I found that I got that error when I change encoding of the tab=20 > delimited file to UTF-8. > Because my data contains non-ascii characters, if I don't use UTF-8, I=20 > get this error. >=20 > ERROR:=C2=A0 invalid byte sequence for encoding "UTF8": 0x82 >=20 >=20 > ... and I read somewhere that if I open the text file in notpad and save= =20 > it with UTF-8 encoding, I can get rid of the error. (When inserting=20 > using pyDev (psycopg2)/Eclipse, that does get rid of the error... Notepad is not a text editor to use in general and in particular for=20 data transformation work. It has limited knowledge of the text format.=20 If you need to do that on Windows use Wordpad or better yet Notepad++: https://notepad-plus-plus.org/=20 >=20 > That's why I changed encoding. >=20 > And now I am stuck with this error. >=20 > But at least, now I am not blaming phpPgAdmin :) > Thanks for the lead. >=20 > BTW, both server and client encoding of my pg db are UTF8. The original encoding was Win-10 (Japanese) correct? >=20 > testdb=3D# SHOW SERVER_ENCODING; >=C2=A0 =C2=A0server_encoding > ----------------- >=C2=A0 =C2=A0UTF8 > (1 row) >=20 > testdb=3D# SHOW CLIENT_ENCODING; >=C2=A0 =C2=A0client_encoding > ----------------- >=C2=A0 =C2=A0UTF8 > (1 row) >=20 > testdb=3D# >=20 >=20 >=C2=A0 =C2=A0 ----- Original Message ----- >=C2=A0 =C2=A0 *From:* Adrian Klaver >=C2=A0 =C2=A0 *To:* s400t@yahoo.co.jp; rob stone ; >=C2=A0 =C2=A0 "pgsql-general@lists.postgresql.org" >=C2=A0 =C2=A0 >=C2=A0 =C2=A0 *Date:* 2018/12/7, Fri 23:47 >=C2=A0 =C2=A0 *Subject:* Re: Importing tab delimited text file using phpPg= Admin >=C2=A0 =C2=A0 5.1 GUI >=20 >=C2=A0 =C2=A0 On 12/7/18 12:28 AM, s400t@yahoo.co.jp wrote: >=C2=A0 =C2=A0 =C2=A0 > Hello Adrian, Rob! >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > Thank you for the comments. >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > Oh, yes, I forgot to mention that I am using Postgr= esql version 9.6. >=C2=A0 =C2=A0 =C2=A0 > I had read somewhere that last supported version wa= s 9.3 or >=C2=A0 =C2=A0 something, >=C2=A0 =C2=A0 =C2=A0 > could be 9.2 as you say. >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > I wanted to use phpPgAdmin, that's why I went back = to 9.6 even if >=C2=A0 =C2=A0 I had >=C2=A0 =C2=A0 =C2=A0 > installed ver. 10 first. >=C2=A0 =C2=A0 =C2=A0 > But if the phpPgAdmin quotes identifiers by default= s, I will need to >=C2=A0 =C2=A0 =C2=A0 > look for some other ways. >=20 >=C2=A0 =C2=A0 I don't think the quoted identifiers are the issue. I am sus= pecting >=C2=A0 =C2=A0 that >=C2=A0 =C2=A0 the import code may be trying to INSERT into the wrong versi= on of the >=C2=A0 =C2=A0 table. Some questions: >=20 >=C2=A0 =C2=A0 1) Which schema did you create spec in? >=20 >=C2=A0 =C2=A0 2) In psql what does \d spec show? >=20 >=20 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > Strictly speaking, I don't need to use the phpPgAdm= in, but I am >=C2=A0 =C2=A0 trying >=C2=A0 =C2=A0 =C2=A0 > to find a GUI way to upload a file quickly (the fil= e has >=C2=A0 =C2=A0 thousands of >=C2=A0 =C2=A0 =C2=A0 > records.) >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > Now, I am using pyDev in Eclipse to insert records,= but I need to >=C2=A0 =C2=A0 use a >=C2=A0 =C2=A0 =C2=A0 > web-based click and upload. >=20 >=C2=A0 =C2=A0 ? >=C2=A0 =C2=A0 https://www.pgadmin.org/=20 >=20 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > If I could find a php version of my python code tha= t would be great! >=C2=A0 =C2=A0 =C2=A0 > My Python code: >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > cur =3D conn.cursor() >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > with io.open(fileName,'r',encoding=3D'utf8') as f: >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 next(f)=C2=A0 # Skip header row= . >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 cur.copy_from(f, tableName, sep= =3D'\t') >=C2=A0 =C2=A0 =C2=A0 > conn.commit() >=C2=A0 =C2=A0 =C2=A0 > cur.close() >=C2=A0 =C2=A0 =C2=A0 > f.close() >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > I have found PHP samples for line by line read and = insert, but >=C2=A0 =C2=A0 that will >=C2=A0 =C2=A0 =C2=A0 > be too slow for me. >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > Cheers! >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 ----- Original Message ----- >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 *From:* rob stone =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 *To:* Adrian Klaver =C2=A0 =C2=A0 >; s400t@yahoo.co.jp >=C2=A0 =C2=A0 ; >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 "pgsql-general@lists.postgresql.org >=C2=A0 =C2=A0 " >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 *Date:* 2018/12/7, Fri 16:47 >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 *Subject:* Re: Importing tab delimited= text file using phpPgAdmin >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 5.1 GUI >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 Hello, >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 On Thu, 2018-12-06 at 21:29 -0800, Adr= ian Klaver wrote: >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > On 12/6/18 7:54 PM, s400t@yah= oo.co.jp >=C2=A0 =C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 wrote: >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > Most GUI tools I am familiar = with quote identifiers by >=C2=A0 =C2=A0 default. >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > > How/where can I tell the ph= pPgAdmin not to add that >=C2=A0 =C2=A0 extra "" around >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > > the >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > > field name? >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > I don't know. I have been und= er the impression that >=C2=A0 =C2=A0 phpPgAdmin was >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > no >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > longer maintained/in use. >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > You might have more luck here= : >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > https://sourceforge.net/p/php= pgadmin/discussion/115884=20 >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > > Thanks for reading and sugg= estions. >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 If you look at phppgadmin on sourcefor= ge, the tarball files >=C2=A0 =C2=A0 are all >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 dated April 15th., 2013. >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 It appears to have stalled at Postgres= version 9.2. >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 I doubt if it will run on versions 10 = or 11. >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 Cheers, >=C2=A0 =C2=A0 =C2=A0 >=C2=A0 =C2=A0 Rob >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=C2=A0 =C2=A0 =C2=A0 > >=20 >=20 >=C2=A0 =C2=A0 --=20 >=C2=A0 =C2=A0 Adrian Klaver >=C2=A0 =C2=A0 adrian.klaver@aklaver.com >=20 >=20 --=20 Adrian Klaver adrian.klaver@aklaver.com =20 ------=_Part_666833_1819731349.1544577329292 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
To Adrian:
Your question: "The original encoding was Win-10 (Japanese) correc= t?"
Let me answer this way:
Yes, I created the file u= sing used Win 10 (J)'s Excel (2016).
When I saved the file as ta= b delimited text, it seems it was saved as ANSI because when I opened it us= ing notepad, I could see it was ANSI.
I then changed the encodin= g to UTF-8 using the notepad .... 
  
But I gave up on importing using the phpPgAdmin. <= /span>
Over the weekend, I found a way using PHP.

Here is a snippet: 
(1) reading file and creating a 2D array:
$fileRead =3D fopen($file, '= r');
$row =3D 1;
$twoDarray =3D a= rray();
while (($line =3D fgetcsv($fileRead, "\t")) != =3D=3D FALSE) {
if($row =3D=3D 1){ $row++; continue; }= //skip header
=09
    $line =3D implode(" ",$line). "\n";<= /div>
    $twoDarray[] =3D $line;
}
fclose($fileRead);
(2)
$con=3Dpg_connect("ho= st=3D$host...");

if (!$con) {
=09die("...");
}

if (pg_copy_from($con, $tableName, $twoDarray) !=3D=3D FALSE) {
=
=09
=09print "Success!";
}
else{
=09print "Failed!";=09
}
=09=09=09=09=09=09
pg_close($con);
//------------------------------

Oh, = yes, I had to convert the tab delimit= ed text file to UTF-8 encoding. For this purpose the notepad was enough.

Some version of Excel seem to offer the option = to save file with UTF-8 encoding, but the one I am using does not have that= option.

Time to move ahead.

=
Thanks!



= ----- Original Message -----
From: Adrian Klaver <adrian.klaver@aklaver.com><= br> To: s40= 0t@yahoo.co.jp; rob stone <floriparob@gmail.com>; "pgsql-general@list= s.postgresql.org" <pgsql-general@lists.postgresql.org> =
Date:= 2018/12/8, Sat 06:35
Subject: Re: Importing tab delimited text file using phpPgAd= min 5.1 GUI

On 12/7= /18 9:04 AM, s400t@yahoo.co.jp wrote:
> I didn't specify any schem= a, so it was created in public schema.
> The error message also says = "public"...
> //-----------------------------------------------------= -------------
> ERROR: column "=EF=BB=BFrec_id" of relation "spec" do= es not exist
> LINE 1: INSERT INTO "public"."spec" ("=EF=BB=BFrec_id"= ,"title_c...
> //----------------------------------------------------= --------------
>
> Output of the \d spec:
>
> >                   T= able "public.spec"
>             C= olumn           |        =   Type           | Modifiers
> ---= -------------------------+-------------------------+-----------
>&nbs= p;  rec_id                &nbs= p;    | character varying(32)   | not null
> = ;  title_category             | cha= racter varying(255)  |
>   doctype     =               | character varying(255)&= nbsp; |
>   ... goes on like this for other columns.
>= ;
> What are you trying to see in the output of \d spec?

My b= asic procedure in troubleshooting is starting from the known and
workin= g out to the unknown. So my questions about the schema(s) and the
table= definition where to establish a know starting point. Also a common
iss= ue that hit this list are multiple versions(across schemas) of an
objec= t in a database and code hitting the wrong version. One of the
signs of= that being error messages of the form you got.


>
> I = don't understand what you mean by the import code is trying to insert
&= gt; in to wrong version of the table.
> I visually checked the left s= ide "menu like" structure of the
> phpPgAdmin- there is no other tab= le of that name.

See above.

>
> You mentioned that = quoted identifiers are not the issue.
> This prompted me to test the = process in a table with a few columns and
> ascii characters.
>= ; Immediately it was clear that quoted identifiers were not to blame.
&g= t;
> I found that I got that error when I change encoding of the tab=
> delimited file to UTF-8.
> Because my data contains non-asc= ii characters, if I don't use UTF-8, I
> get this error.
> > ERROR:  invalid byte sequence for encoding "UTF8": 0x82
> =
>
> ... and I read somewhere that if I open the text file in = notpad and save
> it with UTF-8 encoding, I can get rid of the error= . (When inserting
> using pyDev (psycopg2)/Eclipse, that does get ri= d of the error...

Notepad is not a text editor to use in general and= in particular for
data transformation work. It has limited knowledge o= f the text format.
If you need to do that on Windows use Wordpad or bet= ter yet Notepad++:

https://notepad-plus-plus.org/

>
> That's= why I changed encoding.
>
> And now I am stuck with this erro= r.
>
> But at least, now I am not blaming phpPgAdmin :)
>= ; Thanks for the lead.
>
> BTW, both server and client encodin= g of my pg db are UTF8.

The original encoding was Win-10 (Japanese) = correct?

>
> testdb=3D# SHOW SERVER_ENCODING;
> = ;  server_encoding
> -----------------
>   UTF8<= br>> (1 row)
>
> testdb=3D# SHOW CLIENT_ENCODING;
>&n= bsp;  client_encoding
> -----------------
>   UT= F8
> (1 row)
>
> testdb=3D#
>
>
>&nb= sp;   ----- Original Message -----
>    *From:* Adri= an Klaver <adrian.klaver@aklaver.com>
> = ;   *To:* s400t@yahoo.co.jp; rob stone <floriparob@gmail.c= om>;
>    "pgsql-g= eneral@lists.postgresql.org"
>    <pgsql-general@lists.postgresql.org>
>  &= nbsp; *Date:* 2018/12/7, Fri 23:47
>    *Subject:* Re: Im= porting tab delimited text file using phpPgAdmin
>    5.1 = GUI
>
>    On 12/7/18 12:28 AM, s400t@yahoo.co.jp <mailto:s400t@yahoo.co.jp> wrote:
>      &g= t; Hello Adrian, Rob!
>      >
>   =   > Thank you for the comments.
>      >>      > Oh, yes, I forgot to mention that I am usin= g Postgresql version 9.6.
>      > I had read somew= here that last supported version was 9.3 or
>    something= ,
>      > could be 9.2 as you say.
>  &= nbsp;   >
>      > I wanted to use phpPgAdm= in, that's why I went back to 9.6 even if
>    I had
&g= t;      > installed ver. 10 first.
>    &= nbsp; > But if the phpPgAdmin quotes identifiers by defaults, I will nee= d to
>      > look for some other ways.
> >    I don't think the quoted identifiers are the issue. I a= m suspecting
>    that
>    the import co= de may be trying to INSERT into the wrong version of the
>  &nbs= p; table. Some questions:
>
>    1) Which schema d= id you create spec in?
>
>    2) In psql what does = \d spec show?
>
>
>      >
>&nb= sp;     > Strictly speaking, I don't need to use the phpPgAdmi= n, but I am
>    trying
>      > t= o find a GUI way to upload a file quickly (the file has
>   = ; thousands of
>      > records.)
>  &n= bsp;   >
>      > Now, I am using pyDev in = Eclipse to insert records, but I need to
>    use a
>= ;      > web-based click and upload.
>
>&nbs= p;   ?
>    https://www.pgadmin.org/
>
>    =   >
>      > If I could find a php version = of my python code that would be great!
>      > My = Python code:
>      >
>      &= gt; cur =3D conn.cursor()
>      >
>  &n= bsp;   > with io.open(fileName,'r',encoding=3D'utf8') as f:
>=       >      next(f)  # Skip header r= ow.
>      >      cur.copy_from(f, t= ableName, sep=3D'\t')
>      > conn.commit()
>= ;      > cur.close()
>      > f.c= lose()
>      >
>      >>      > I have found PHP samples for line by line re= ad and insert, but
>    that will
>    &nb= sp; > be too slow for me.
>      >
> =     > Cheers!
>      >
>  =     >
>      >
>    &n= bsp; >    ----- Original Message -----
>    &n= bsp; >    *From:* rob stone <floriparob@gmail.com<= br>>    <mailto:floriparob@gmail.com>>
&= gt;      >    *To:* Adrian Klaver <adrian.klaver@aklaver.com
>    <mailto:adrian.klaver@aklaver.com>>; s400t@yahoo.co.jp
>= ;    <mailto:s400t@yahoo.co.jp>;
>    &= nbsp; >    "pgsql-general@lis= ts.postgresql.org
>    <mailto:pgsql-general@lists.postgresql.org>"
>  &nbs= p;   >    <pgsql-gene= ral@lists.postgresql.org
>    <mailto:pgsql-general@lists.postgresql.org>>
>&= nbsp;     >    *Date:* 2018/12/7, Fri 16:47
>&= nbsp;     >    *Subject:* Re: Importing tab delimite= d text file using phpPgAdmin
>      >    = 5.1 GUI
>      >
>      >&n= bsp;   Hello,
>      >
>    &n= bsp; >    On Thu, 2018-12-06 at 21:29 -0800, Adrian Klaver wro= te:
>      >      > On 12/6/18 7:= 54 PM, s400t@yahoo.co.jp
>    <mailto:s400t@yahoo.co.= jp> <mailto:s400t@yahoo.co.jp
>    <mailto= := s400t@yahoo.co.jp>>
>      >   = wrote:
>      >      >
>&n= bsp;     >      > Most GUI tools I am famili= ar with quote identifiers by
>    default.
>  &= nbsp;   >      > > How/where can I tell the ph= pPgAdmin not to add that
>    extra "" around
> = ;     >      > > the
>   =   >      > > field name?
>   =   >      >
>      > = ;     > I don't know. I have been under the impression that>    phpPgAdmin was
>      >  &= nbsp;   > no
>      >      &= gt; longer maintained/in use.
>      >   =   >
>      >      > You = might have more luck here:
>      >    &n= bsp; >
>      >      > https://sourceforge.net/p/phppgadmin/discussion/115884
> = ;     >      >
>      &= gt;      > >
>      >  &n= bsp;   > > Thanks for reading and suggestions.
>  &nb= sp;   >      >
>      >&n= bsp;     >
>      >
>  &nbs= p;   >    If you look at phppgadmin on sourceforge, the t= arball files
>    are all
>      >=     dated April 15th., 2013.
>      >&nbs= p;   It appears to have stalled at Postgres version 9.2.
> =     >    I doubt if it will run on versions 10 or 1= 1.
>      >
>      >  =   Cheers,
>      >    Rob
>&nb= sp;     >
>      >
>   = ;   >
>      >
>      = >
>      >
>
>
>   = ; --
>    Adrian Klaver
>    adrian.klaver@aklaver.com <mailto:adrian.klaver@= aklaver.com>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


------=_Part_666833_1819731349.1544577329292--