Difference between revisions of "M-database"

From Wiki
Jump to navigation Jump to search
m
m
Line 3: Line 3:
 
{{todo|more examples and explanation}}
 
{{todo|more examples and explanation}}
  
<texcode>
+
<context source=yes mode=mkiv>
\usemodule[database]
 
 
 
\defineseparatedlist [MyTable]
 
[
 
    separator=tab,
 
    before=\bTABLE, after=\eTABLE,
 
    first=\bTR, last=\eTR,
 
    left=\bTD, right=\eTD,
 
    commentchar=\letterpercent,
 
]
 
% The % must be set as the comment char explicitly, because by default its catcode is changed.
 
 
 
% columns are separated with a tab (not with a space)
 
\startMyTable
 
% Cows in Holland, 1 unit meaning 1000 cows.
 
Cows Total Milking Pregnant
 
01/1995 1709 1449 260
 
01/1996 1713 1444 269
 
... ... ... ...
 
11/2004 1457 1295 161
 
11/2005 1421 1263 158
 
\stopMyTable
 
</texcode>
 
 
 
<context>
 
 
\setuplayout[scale=0.8]
 
\setuplayout[scale=0.8]
 
\setupcolors[state=start]
 
\setupcolors[state=start]
Line 59: Line 34:
  
 
%load from a file
 
%load from a file
\processseparatedfile[TSV][cows2.tsv]
+
%\processseparatedfile[TSV][cows.tsv]
  
 
</context>
 
</context>

Revision as of 20:57, 26 March 2014

< m-database source | Tables Overview >


TODO: more examples and explanation (See: To-Do List)


\setuplayout[scale=0.8]
\setupcolors[state=start]
\usemodule[database]

\defineseparatedlist
  [MyTable]
  [separator=tab,
   left=\bTD,right=\eTD,
   first=\bTR,last=\eTR,
   before=\bTABLE,after=\eTABLE]

\setupTABLE[c][each][align=flushright,width=2.5cm,align=middle]
\setupTABLE[r][1][background=color,backgroundcolor=gray]
\startMyTable
Cows	Total	Milking	Pregnant
01/1995	1709	1449	260
01/1996	1713	1444	269
01/1997	1606	1387	219
01/1998	1634	1416	218
11/1998	1558	1350	208
11/1999	1520	1307	212
11/2000	1475	1285	190
11/2001	1496	1345	151
11/2002	1498	1338	160
11/2003	1492	1324	169
11/2004	1457	1295	161
11/2005	1421	1263	158
\stopMyTable

%load from a file
%\processseparatedfile[TSV][cows.tsv]

Links