From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106732 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Geert Dobbels Newsgroups: gmane.comp.tex.context Subject: Re: xtable headers and handlecsv loop Date: Fri, 3 Apr 2020 15:36:25 +0200 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0876702035959476237==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="48349"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Apr 03 15:36:41 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jKMUz-000CT1-2O for gctc-ntg-context-518@m.gmane-mx.org; Fri, 03 Apr 2020 15:36:41 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 736C8183014; Fri, 3 Apr 2020 15:36:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MHbSi4gK7Zmp; Fri, 3 Apr 2020 15:36:30 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6BDC9183004; Fri, 3 Apr 2020 15:36:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id BB15B182FFD for ; Fri, 3 Apr 2020 15:36:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xrlf8W-U0WP3 for ; Fri, 3 Apr 2020 15:36:28 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.41; helo=mail-wm1-f41.google.com; envelope-from=dobbels.geert@googlemail.com; receiver= Original-Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 1830C182C24 for ; Fri, 3 Apr 2020 15:36:28 +0200 (CEST) Original-Received: by mail-wm1-f41.google.com with SMTP id t8so7179915wmi.2 for ; Fri, 03 Apr 2020 06:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=4yHSNP8J1U94qJP2G7LpRaFpqIrBvXB3f4MnMq4NVto=; b=URmSHmkEM9MkJNoH/21kJB4SamjCfdyqMKpzQyBlFZw3Zv213zRc5d3XAm2k0GRoYj bk54MJYBH4boN752QXAw2H1wSkoqfZH8WeVJNAYyM2q+ucS+jlH9jEDNFEY4vHXj6eMa 8NjiXruhd/lVGake9A7TdsYhYMx+a382cN85S837b0srNplQ5Z9dbMtxtOzCTjmawCIH TFL6EM3XZu9e0QiFlNYjoggMbVKlVSuXJx/ZzyHyC0dFibASHSHDhT3I2FOUGE1XEVv2 uV7OTl6hW/4RczgfZJQPV1xwXXS3ct027zaDtRC2XcwrSpndBRbE5xRZONoWn4lwQchG 0Z2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=4yHSNP8J1U94qJP2G7LpRaFpqIrBvXB3f4MnMq4NVto=; b=bK5BctfNROXlZCp6kpV6jRHG5Htsu9y2iJMXRWTt3V2je9I4joOA4ByEgxjxgCcm/Q xOoiXnkCcdRuixfH5VD86EaJxGshP+duMW3fdrc9d6D7GfQdN1GShn5AXntohgsRhu/n Ph8tCPb/EXEdGHszleIVDhRU0w7FVb5jtObbNTkyQtUIADiFsuTxk7gyAyylNx94EFem ge9epMAFvnGhhpJuo1p+ZwXPLk0i1VODYWtngKgd+nQC41HW61UhShcknDjZeW7O+skb yrZ0UHJAjTed1Aghpnsz1DFIroCXQlfCZ4YmK48R8teMvYe4edbsYpA7D8kJfsm87zDC 77DA== X-Gm-Message-State: AGi0Pub1loB9RLotvlPJupVaaLg/EBcNS0AFkl2JVsgE2YCiSxRdxhpe 3PXFlwnr1VbOzImyPLeQaKn5urhs X-Google-Smtp-Source: APiQypKL20e6aAU2ECAk7VK2FiZmNQpE14xJ/XcBILLbYnue59OnTsN1vRjESBucqa2xWeVMZPxE8g== X-Received: by 2002:a05:600c:1:: with SMTP id g1mr8860456wmc.49.1585920987474; Fri, 03 Apr 2020 06:36:27 -0700 (PDT) Original-Received: from [192.168.1.49] (186.red-80-39-46.staticip.rima-tde.net. [80.39.46.186]) by smtp.googlemail.com with ESMTPSA id h5sm12003053wro.83.2020.04.03.06.36.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Apr 2020 06:36:26 -0700 (PDT) X-Google-Original-From: Geert Dobbels In-Reply-To: Content-Language: en-US X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 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" Xref: news.gmane.io gmane.comp.tex.context:106732 Archived-At: This is a multi-part message in MIME format. --===============0876702035959476237== Content-Type: multipart/alternative; boundary="------------D6DB2967D106DE034A58A356" Content-Language: en-US This is a multi-part message in MIME format. --------------D6DB2967D106DE034A58A356 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Wolfgang, Thanks for this.  It works, however, the page where the table starts has three lines of text before the table starts.  After inserting "split=repeat", the table jumps to the next page, leaving the rest of the page with the three lines of text completely blank.  This did not happen without the "split=repeat". Geert On 03/04/2020 12:18, Wolfgang Schuster wrote: > Geert Dobbels schrieb am 03.04.2020 um 11:57: >> Hello, >> >> The sample below has 2 problems I cannot find the solution for: >> >> I am reading a table from a CSV file and want to typeset it via \xtable. >> >> The xtable as defined below works, it splits over several pages, but >> the header does not repeat. I have seen examples in the mailing list >> where people put the "\startxtable.....\stopxtable" within a >> \placefigure, but as soon as I try this, I get an error message: >> "missing } or endgroup", although I doublechecked the "}" and I see >> no error. >> >> The other issue I have: Since xtable requires me to read the header >> line separately in order to put it between \startxtablehead and >> \stopxtablehead, I access the csv buffer twice: the first time, I >> only read the first line, and the second time, I read starting from >> the second line. My problem here is that I do not know beforehand the >> number of lines in the csv file. So in my second \doloopfromto I give >> the second argument a number high enough to be sure it reads all the >> lines. It works fine, but I would like to know if there is a way to >> read the number of lines in the csv file to use the exact number of >> lines, instead of guessing. >> >> \usemodule[handlecsv] >> >> \opencsvfile{systaprov2.csv} >> >> \starttext >> >> >> \startbuffer[loop] >> \startxrow >> \startxcell[left] \cA \stopxcell >> \startxcell[left] \cB \stopxcell >> \startxcell[left] \cC \stopxcell >> \startxcell[left] \cD \stopxcell >> \startxcell \cE \stopxcell >> \startxcell[left] \cF \stopxcell >> \startxcell \cG \stopxcell >> \startxcell \cH \stopxcell >> \doifdefined{cI}{\startxcell \cI \stopxcell} >> \doifdefined{cJ}{\startxcell \cJ \stopxcell} >> \doifdefined{cK}{\startxcell [left] \cK \stopxcell} >> \stopxrow >> \stopbuffer >> >> \setupxtable[offset=0cm, >> frame=off, >> bottomframe=on, >> framecolor=gray, >> option=stretch, >> align=middle] >> >> \setupxtable[head][background=color, >> backgroundcolor=gray, >> topframe=on, >> bottomframe=on, >> framecolor=black, >> foregroundcolor=blue] >> >> \setupxtable[left][align=right] >> >> \startxtable[header=repeat] > > Add "split=repeat" to \startxtable. > >> \startxtablehead[head] >> \doloopfromto{1}{1}{\getbuffer[loop]} >> \stopxtablehead >> \startxtablebody >> \doloopfromto{2}{500}{\getbuffer[loop]} >> \stopxtablebody >> >> \stopxtable >> >> \stoptext > > Wolfgang -- -- *_IHTS Approvals S.L._* Geert Dobbels                                                         geert@ihts.eu Zubiegi 11, E-01139 Bitoriano (Spain)                  0034 945 462633 ihts.eu --------------D6DB2967D106DE034A58A356 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
Wolfgang,

Thanks for this.  It works, however, the page where the table starts has
three lines of text before the table starts.  After inserting
"split=repeat", the table jumps to the next page, leaving the rest of
the page with the three lines of text completely blank.  This did not
happen without the "split=repeat".

Geert


On 03/04/2020 12:18, Wolfgang Schuster wrote:
Geert Dobbels schrieb am 03.04.2020 um 11:57:
Hello,

The sample below has 2 problems I cannot find the solution for:

I am reading a table from a CSV file and want to typeset it via \xtable.

The xtable as defined below works, it splits over several pages, but the header does not repeat. I have seen examples in the mailing list where people put the "\startxtable.....\stopxtable" within a \placefigure, but as soon as I try this, I get an error message: "missing } or endgroup", although I doublechecked the "}" and I see no error.

The other issue I have: Since xtable requires me to read the header line separately in order to put it between \startxtablehead and \stopxtablehead, I access the csv buffer twice: the first time, I only read the first line, and the second time, I read starting from the second line. My problem here is that I do not know beforehand the number of lines in the csv file. So in my second \doloopfromto I give the second argument a number high enough to be sure it reads all the lines. It works fine, but I would like to know if there is a way to read the number of lines in the csv file to use the exact number of lines, instead of guessing.

\usemodule[handlecsv]

\opencsvfile{systaprov2.csv}

\starttext


\startbuffer[loop]
\startxrow
\startxcell[left] \cA \stopxcell
\startxcell[left] \cB \stopxcell
\startxcell[left] \cC \stopxcell
\startxcell[left] \cD \stopxcell
\startxcell \cE \stopxcell
\startxcell[left] \cF \stopxcell
\startxcell \cG \stopxcell
\startxcell \cH \stopxcell
\doifdefined{cI}{\startxcell \cI \stopxcell}
\doifdefined{cJ}{\startxcell \cJ \stopxcell}
\doifdefined{cK}{\startxcell [left] \cK \stopxcell}
\stopxrow
\stopbuffer

\setupxtable[offset=0cm,
frame=off,
bottomframe=on,
framecolor=gray,
option=stretch,
align=middle]

\setupxtable[head][background=color,
backgroundcolor=gray,
topframe=on,
bottomframe=on,
framecolor=black,
foregroundcolor=blue]

\setupxtable[left][align=right]

\startxtable[header=repeat]

Add "split=repeat" to \startxtable.

\startxtablehead[head]
\doloopfromto{1}{1}{\getbuffer[loop]}
\stopxtablehead
\startxtablebody
\doloopfromto{2}{500}{\getbuffer[loop]}
\stopxtablebody

\stopxtable

\stoptext

Wolfgang

--
--
IHTS Approvals S.L.
Geert Dobbels                                                         geert@ihts.eu
Zubiegi 11, E-01139 Bitoriano (Spain)                  0034 945 462633
ihts.eu
--------------D6DB2967D106DE034A58A356-- --===============0876702035959476237== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============0876702035959476237==--