From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/79467 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: "Hiding" columns in m-database & TABLE Date: Fri, 23 Nov 2012 13:38:35 +0100 Message-ID: <20121123123835.GB8788@phlegethon.router_intern> References: <20121122125702.2c1bc8ff@aga-netbook> <20121122153645.7bf5be85@aga-netbook> <50AE6708.5020109@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0313962928==" X-Trace: ger.gmane.org 1353674354 7703 80.91.229.3 (23 Nov 2012 12:39:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Nov 2012 12:39:14 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Nov 23 13:39:19 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TbsXM-0000md-Tm for gctc-ntg-context-518@m.gmane.org; Fri, 23 Nov 2012 13:39:16 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 125AB10240; Fri, 23 Nov 2012 13:38:56 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oU2mjza266wo; Fri, 23 Nov 2012 13:38:50 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id DCF2A10209; Fri, 23 Nov 2012 13:38:47 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0D97310209 for ; Fri, 23 Nov 2012 13:38:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dYiJqxhMQEHn for ; Fri, 23 Nov 2012 13:38:42 +0100 (CET) Original-Received: from filter3-ams.mf.surf.net (filter3-ams.mf.surf.net [192.87.102.71]) by balder.ntg.nl (Postfix) with ESMTP id AA00B10202 for ; Fri, 23 Nov 2012 13:38:42 +0100 (CET) Original-Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by filter3-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id qANCcdvn006764 for ; Fri, 23 Nov 2012 13:38:40 +0100 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id qANCcdpe025607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 23 Nov 2012 13:38:39 +0100 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id qANCccGA028329 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 23 Nov 2012 13:38:38 +0100 Original-Received: from localhost (p4FFFDB73.dip.t-dialin.net [79.255.219.115]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id qANCcbMx018665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 23 Nov 2012 13:38:37 +0100 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: <50AE6708.5020109@wxs.nl> X-Operating-System: Linux phlegethon 3.6.6-1-ARCH X-License: "CC-BY-SA 3.0" User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.210.211; country=DE; latitude=51.0000; longitude=9.0000; http://maps.google.com/maps?q=51.0000,9.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 03Ir0CDM6 - 5855dcce4488 - 20121123 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.71 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:79467 Archived-At: --===============0313962928== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FkmkrVfFsRoUs1wW" Content-Disposition: inline --FkmkrVfFsRoUs1wW Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7 > On 11/22/2012 3:36 PM, Marcin Borkowski wrote: > >Dnia 2012-11-22, o godz. 13:26:52 > >Mojca Miklavec napisa=C5=82(a): > > > >>On Thu, Nov 22, 2012 at 12:57 PM, Marcin Borkowski wrote: > >>>le) in order to > >>>typeset a (nice) TABLE. However, I have a few columns I'd like to > >>>omit. I can (of course) hand-edit the csv file; but is there a way > >>>to do it automatically? Something like > >>> > >>>\setupTABLE[column][3,4,5][kill] > >>> > >>>I did [empty=3Dyes,width=3D0pt] in place of [kill], and it worked, but > >>>it seems like a hack (and I don't know whether it does actually > >>>process the cells I'm omitting - which in my case wouldn't bother > >>>me, but might be an additional layer of inelegance;)). And better > >>>ideas? > >> > >>If you have up to 9 columns, you could use > >> > >> \def\ProcessingLine#1#2#3#4#5#6#7{% > >> \bTR\bTD#1\eTD\bTD#2\eTD\bTD#6\eTD\bTD#7\eTD} > >> > >>and then [command=3D\ProcessingLine] > > > >Well, something like 20 columns (on A4 landscape). ;) > > > >It turns out that my method somehow doesn't work well without setting > >also height=3D0pt; then it's fine, but I'm still wondering about a > >cleaner way. >=20 > I've added a splutter to the core: >=20 > \startluacode >=20 > local mycsvsplitter =3D utilities.parsers.csvsplitter { > separator =3D ",", > quote =3D '"', > } >=20 > local crap =3D [[ > "1","2","3","4" > "a","b","c","d" > ]] >=20 > local mycrap =3D mycsvsplitter(crap) >=20 > context.bTABLE() > for i=3D1,#mycrap do > context.bTR() > local c =3D mycrap[i] > for i=3D1,#c do > context.bTD() > context(c[i]) > context.eTD() > end > context.eTR() > end > context.eTABLE() >=20 > \stopluacode Hi Hans, although csv is not a standard per se there is nevertheless an rfc: . Can we have an optional rfc-compliant parser as well? That entails interpreting the first line as field header if it consists entirely of unquoted fields -- neat feature as one can treat these as column identifiers to query fields in a more natural fashion. =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7= =C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2=B7=C2= =B7=C2=B7=C2=B7 \starttext \startluacode local P, R, V, S, C, Ct, Cs, Carg, Cc, Cg, Cf =3D lpeg.P, lpeg.R, lpeg.V, l= peg.S, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cc, lpeg.Cg, lpeg.Cf local lpegmatch =3D lpeg.match local patterns =3D lpeg.patterns local newline =3D patterns.newline ----------------------------------------------------------------------- -- RFC 4180 csv parser ----------------------------------------------------------------------- -- based on http://tools.ietf.org/html/rfc4180 -- notable deviations from the RFC grammar: -- =C2=B7 allow overriding =E2=80=9Ccomma=E2=80=9D and =E2=80=9Cquote=E2= =80=9D chars in spec -- =C2=B7 the =E2=80=9Ctextdata=E2=80=9D rule is extrapolated to mean, ba= sically, -- =E2=80=9Ceverything but the quote character=E2=80=9D, not just the c= haracter -- range as in the RFC -- =C2=B7 newline from l-lpeg.lua instead of =E2=80=9Ccrlf=E2=80=9D local rfc4180_spec =3D { separator =3D ",", quote =3D [["]] } utilities.parsers.rfc4180_splitter =3D function (specification) specification =3D specification or rfc4180_spec local separator =3D specification.separator --> rfc: COMMA local quotechar =3D P(specification.quote) --> DQUOTE local dquotechar =3D quotechar * quotechar --> 2DQUOTE / specification.quote local separator =3D S(separator ~=3D "" and separator or ",") local escaped =3D quotechar * Cs((dquotechar + (1 - quotechar))^0) * quotechar local non_escaped =3D C((1 - quotechar - newline - separator)^1) local field =3D escaped + non_escaped local record =3D Ct(field * (separator * field)^0) local name =3D field -- sic! local header =3D Cg(Ct(name * (separator * name)^0), "header") local file =3D Ct((header * newline)^-1 -- optional header * record * (newline * record)^0 * newline^0) return function (data) return lpegmatch (file, data) end end ----------------------------------------------------------------------- -- example writer (natural table) ----------------------------------------------------------------------- local print_csv_table =3D function (tab) local header =3D tab.header context.setupTABLE({ frame =3D "off" }) context.setupTABLE({"header"}, { background =3D "screen" }) context.bTABLE() if header then context.bTABLEhead() context.bTR() for i=3D1,#header do context.bTH() context(header[i]) context.eTH() end context.eTR() context.eTABLEhead() end context.bTABLEbody() for i=3D1,#tab do context.bTR() local c =3D tab[i] for i=3D1,#c do context.bTD() context(c[i]) context.eTD() end context.eTR() end context.eTABLEbody() context.eTABLE() end ----------------------------------------------------------------------- -- usage ----------------------------------------------------------------------- local mycsvsplitter =3D utilities.parsers.rfc4180_splitter () local crap =3D [[ first,second,third,fourth "1","2","3","4" "a","b","c","d" "foo","bar""baz","boogie","xyzzy" ]] local mycrap =3D mycsvsplitter(crap) print_csv_table (mycrap) ----------------------------------------------------------------------- \stopluacode \stoptext --FkmkrVfFsRoUs1wW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlCvbksACgkQ02lYlJYWs9IaxACgo1L8Eori+a3HohBTLFbWTnos eSoAn07AIwx1DSyRtx0RjmC+HXrtLWxo =cyBr -----END PGP SIGNATURE----- --FkmkrVfFsRoUs1wW-- --===============0313962928== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============0313962928==--