ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* startCSV Wiki, Natural Table
@ 2020-11-24 17:44 Fabrice L
  2020-11-24 17:52 ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice L @ 2020-11-24 17:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I was using in the past (MKII) a snippet of code to produce (natural) tables from CSV. I was trying to compile my code with MKIV, but this does not work anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV (probably my error !). 

So I came back to the wiki, where my code came from, and the code below is just a copy for the wiki. It is supposed to make a table with three columns, but there is only one column in the resulting table…  I admit I do not understand the code, but is there is missing \eTR somewhere ?

Thanks for any help.
Fabrice.

Ps: in case someone is interested, I use this to produce statistical tables for teaching. I can share.. ! 

% ------------------------------------------------------
\starttext

% Iterate over all the lines of text captured with \obeylines active
% command to call is first argument, is not called for empty lines
\bgroup
\obeylines
\gdef\ProcessLines#1#2{\doProcessLines{#1}#2^^M\doProcessLines}%
\gdef\doProcessLines#1#2^^M#3\doProcessLines{%
 \doifnotempty{#2}{#1{#2}}%
 \doifnotempty{#3}{\doProcessLines{#1}#3\doProcessLines}%
}%
\egroup

\def\startCSV{\bgroup\obeylines\dostartCSV}

\def\TBLentry#1{\bTD#1\eTD}
\def\TBLline#1{\bTR\processcommalist[#1]\TBLentry}

\def\dostartCSV#1\stopCSV{%
  \bTABLE
  \ProcessLines\TBLline{#1}%
  \eTABLE
  \egroup
}

% some additional settings for the table may be made as well
\setupTABLE[c][2][style=\tt]
\setupTABLE[c][3][align=middle]
\setupTABLE[r][1][style=bold] 

\startCSV
Name,Email,Accepted
\CONTEXT,worth@trying.to,Yes
Hans,main@developer.of,Yes
Bug,get@rid.of,No
\stopCSV

\stoptext
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: startCSV Wiki, Natural Table
  2020-11-24 17:44 startCSV Wiki, Natural Table Fabrice L
@ 2020-11-24 17:52 ` Wolfgang Schuster
  2020-11-24 18:08   ` Fabrice L
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2020-11-24 17:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Fabrice L schrieb am 24.11.2020 um 18:44:
> Hi,
> 
> I was using in the past (MKII) a snippet of code to produce (natural) tables from CSV. I was trying to compile my code with MKIV, but this does not work anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV (probably my error !).
> 
> So I came back to the wiki, where my code came from, and the code below is just a copy for the wiki. It is supposed to make a table with three columns, but there is only one column in the resulting table…  I admit I do not understand the code, but is there is missing \eTR somewhere ?

Use the database module.

\usemodule[database]

\defineseparatedlist
   [CSV]
   [separator={,},
       before=\bTABLE,
        after=\eTABLE,
        first=\bTR,
         last=\eTR,
         left=\bTD,
        right=\eTD]

\starttext

\startCSV
1,2,3
3,5,6
7,8,9
\stopCSV

\stoptext

Wolfgang
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: startCSV Wiki, Natural Table
  2020-11-24 17:52 ` Wolfgang Schuster
@ 2020-11-24 18:08   ` Fabrice L
  2020-11-24 18:36     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice L @ 2020-11-24 18:08 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users



> Le 24 nov. 2020 à 12:52, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> a écrit :
> 
> Fabrice L schrieb am 24.11.2020 um 18:44:
>> Hi,
>> I was using in the past (MKII) a snippet of code to produce (natural) tables from CSV. I was trying to compile my code with MKIV, but this does not work anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV (probably my error !).
>> So I came back to the wiki, where my code came from, and the code below is just a copy for the wiki. It is supposed to make a table with three columns, but there is only one column in the resulting table…  I admit I do not understand the code, but is there is missing \eTR somewhere ?
> 
> Use the database module.
> 
> \usemodule[database]
> 
> \defineseparatedlist
>  [CSV]
>  [separator={,},
>      before=\bTABLE,
>       after=\eTABLE,
>       first=\bTR,
>        last=\eTR,
>        left=\bTD,
>       right=\eTD]
> 
> \starttext
> 
> \startCSV
> 1,2,3
> 3,5,6
> 7,8,9
> \stopCSV
> 
> \stoptext
> 
> Wolfgang

Wolfgang, thanks. I have seen the use if the database module on the wiki, but was trying to do without it, the reason is that my documents are often shared with colleagues, for which installation of modules is most often very difficult. 
Anyway, I will use the database module this time, so simple ! Thanks again.

Fabrice
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: startCSV Wiki, Natural Table
  2020-11-24 18:08   ` Fabrice L
@ 2020-11-24 18:36     ` Wolfgang Schuster
  2020-11-24 20:13       ` Fabrice L
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2020-11-24 18:36 UTC (permalink / raw)
  To: Fabrice L; +Cc: mailing list for ConTeXt users

Fabrice L schrieb am 24.11.2020 um 19:08:
>> Le 24 nov. 2020 à 12:52, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> a écrit :
>>
>> Fabrice L schrieb am 24.11.2020 um 18:44:
>>> Hi,
>>> I was using in the past (MKII) a snippet of code to produce (natural) tables from CSV. I was trying to compile my code with MKIV, but this does not work anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV (probably my error !).
>>> So I came back to the wiki, where my code came from, and the code below is just a copy for the wiki. It is supposed to make a table with three columns, but there is only one column in the resulting table…  I admit I do not understand the code, but is there is missing \eTR somewhere ?
>> Use the database module.
>>
>> \usemodule[database]
>>
>> \defineseparatedlist
>>   [CSV]
>>   [separator={,},
>>       before=\bTABLE,
>>        after=\eTABLE,
>>        first=\bTR,
>>         last=\eTR,
>>         left=\bTD,
>>        right=\eTD]
>>
>> \starttext
>>
>> \startCSV
>> 1,2,3
>> 3,5,6
>> 7,8,9
>> \stopCSV
>>
>> \stoptext
>>
>> Wolfgang
> Wolfgang, thanks. I have seen the use if the database module on the wiki, but was trying to do without it, the reason is that my documents are often shared with colleagues, for which installation of modules is most often very difficult.

There is nothing to install because the database module is part of ConTeXt.

Wolfgang

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: startCSV Wiki, Natural Table
  2020-11-24 18:36     ` Wolfgang Schuster
@ 2020-11-24 20:13       ` Fabrice L
  0 siblings, 0 replies; 5+ messages in thread
From: Fabrice L @ 2020-11-24 20:13 UTC (permalink / raw)
  To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1661 bytes --]



> Le 24 nov. 2020 à 13:36, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> a écrit :
> 
> Fabrice L schrieb am 24.11.2020 um 19:08:
>>> Le 24 nov. 2020 à 12:52, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> a écrit :
>>> 
>>> Fabrice L schrieb am 24.11.2020 um 18:44:
>>>> Hi,
>>>> I was using in the past (MKII) a snippet of code to produce (natural) tables from CSV. I was trying to compile my code with MKIV, but this does not work anymore. As a matter of fact, it doe snot work at all, nor MKII, nor MKIV (probably my error !).
>>>> So I came back to the wiki, where my code came from, and the code below is just a copy for the wiki. It is supposed to make a table with three columns, but there is only one column in the resulting table…  I admit I do not understand the code, but is there is missing \eTR somewhere ?
>>> Use the database module.
>>> 
>>> \usemodule[database]
>>> 
>>> \defineseparatedlist
>>>  [CSV]
>>>  [separator={,},
>>>      before=\bTABLE,
>>>       after=\eTABLE,
>>>       first=\bTR,
>>>        last=\eTR,
>>>        left=\bTD,
>>>       right=\eTD]
>>> 
>>> \starttext
>>> 
>>> \startCSV
>>> 1,2,3
>>> 3,5,6
>>> 7,8,9
>>> \stopCSV
>>> 
>>> \stoptext
>>> 
>>> Wolfgang
>> Wolfgang, thanks. I have seen the use if the database module on the wiki, but was trying to do without it, the reason is that my documents are often shared with colleagues, for which installation of modules is most often very difficult.
> 
> There is nothing to install because the database module is part of ConTeXt.

I see… wonderfull ! Thanks a lot for the help. 
> 
> Wolfgang

Fabrice.

[-- Attachment #1.2: Type: text/html, Size: 5710 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-24 20:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 17:44 startCSV Wiki, Natural Table Fabrice L
2020-11-24 17:52 ` Wolfgang Schuster
2020-11-24 18:08   ` Fabrice L
2020-11-24 18:36     ` Wolfgang Schuster
2020-11-24 20:13       ` Fabrice L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).