Difference between revisions of "M-database"

From Wiki
Jump to navigation Jump to search
m (Reverted edits by 202.234.131.166 (Talk); changed back to last version by Taco)
(new example)
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
< [[source:m-database.tex|m-database]] | [[Tables Overview]] >
+
< [[source:m-database.tex|m-database source]] | [[Tables Overview]] >
  
 
{{todo|more examples and explanation}}
 
{{todo|more examples and explanation}}
  
<texcode>
+
== Inline ==
\defineseparatedlist
 
  [MyTable]
 
  [separator={^^I}, % should be 'separator=tab[ulator]'
 
  left=\bTD,right=\eTD,
 
  first=\bTR,last=\eTR,
 
  before=\bTABLE,after=\eTABLE]
 
  
\startMyTable % columns are separated with a tab (not with a space)
+
(This might be outdated)
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>
+
<context source=yes mode=mkiv>
 
\setuplayout[scale=0.8]
 
\setuplayout[scale=0.8]
 
\setupcolors[state=start]
 
\setupcolors[state=start]
 
\usemodule[database]
 
\usemodule[database]
 
\catcode`\^^I=12
 
  
 
\defineseparatedlist
 
\defineseparatedlist
 
   [MyTable]
 
   [MyTable]
   [separator={^^I},
+
   [separator=tab,
 
   left=\bTD,right=\eTD,
 
   left=\bTD,right=\eTD,
 
   first=\bTR,last=\eTR,
 
   first=\bTR,last=\eTR,
Line 52: Line 36:
 
11/2005 1421 1263 158
 
11/2005 1421 1263 158
 
\stopMyTable
 
\stopMyTable
 +
 +
%load from a file
 +
%\processseparatedfile[TSV][cows.tsv]
 +
 +
</context>
 +
 +
==Data from File==
 +
 +
(This is current as of 2016-05-31)
 +
 +
<context source=yes mode=mkiv>
 +
\usemodule[database]
 +
 +
\starttext
 +
 +
\defineseparatedlist
 +
[test]
 +
[separator=space, % tab
 +
  before=\bTABLE,after=\eTABLE,
 +
  first=\bTR,last=\eTR,
 +
  left=\bTD,right=\eTD]
 +
 +
\processdatabasefile[test][csv.csv]
 +
 +
\stoptext
  
 
</context>
 
</context>
Line 57: Line 66:
 
==Links==
 
==Links==
  
* [http://www.physik.uni-freiburg.de/~doerr/exceltex/index.en.html exceltex] - LaTeX package to fetch data from Excel documents ([http://www.rubygarden.org/ruby?ScriptingExcel])
+
* [http://www.physik.uni-freiburg.de/~doerr/exceltex/index.en.html exceltex] - LaTeX package to fetch data from Excel documents ([http://www.rubygarden.org/ruby?ScriptingExcel Scripting Excel article])
 +
* [http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=tab4tex tab4tex] - Preprocessor for LaTeX tabular environments
 +
* [http://dl.contextgarden.net/myway/csv.pdf MyWay] about CSV
 +
* [http://www.ntg.nl/maps/42/12.pdf Using ConTeXt with databases] (article in NTG-MAPS)
 +
 
 +
[[Category:Tables]]

Latest revision as of 04:03, 1 June 2016

< m-database source | Tables Overview >


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


Inline

(This might be outdated)

\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]

Data from File

(This is current as of 2016-05-31)

\usemodule[database]

\starttext

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

\processdatabasefile[test][csv.csv]

\stoptext

internal error: copy error 1LWKBY/cropped.pdf

Links