Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Examples using current templates

  • Loading branch information...
commit 8690eb621b7d9a78cecb496593b21583809de52b 1 parent cfa3fde
@jnothman authored
View
12 examples/example_html_table.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+import os.path
+import datatemplate
+
+EXAMPLE_DIR = os.path.dirname(os.path.abspath(__file__))
+TEMPLATE_DIR = os.path.join(os.path.dirname(EXAMPLE_DIR), 'templates')
+
+contexts = [
+ datatemplate.csv('data', os.path.join(EXAMPLE_DIR, 'large_table.tsv'), dialect='tab'),
+]
+template_path = os.path.join(TEMPLATE_DIR, 'html_table.tpl')
+print datatemplate.render(open(template_path), contexts)
View
9 examples/example_html_table.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+if [ '!' -e "large_table.tsv" ]
+then
+ echo 'Error: Must be executed from examples directory' >&2
+ exit 1
+fi
+
+datatemplate --tsv data=large_table.tsv < ../templates/html_table.tpl
View
28 examples/example_html_table_from_db_records.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import os.path
+import datatemplate
+
+EXAMPLE_DIR = os.path.dirname(os.path.abspath(__file__))
+TEMPLATE_DIR = os.path.join(os.path.dirname(EXAMPLE_DIR), 'templates')
+
+contexts = [
+ datatemplate.csvsql(os.path.join(EXAMPLE_DIR, 'large_table.tsv'), dialect='tab'),
+ {
+ 'field': '`Metric 1 F`',
+ 'where': 'Test="test1"',
+ 'corner': 'Model',
+ 'rows': [
+ ('1', 'Model="model1"'),
+ ('2', 'Model="model2"'),
+ ('3', 'Model="model3"'),
+ ],
+ 'cols': [
+ ('English', 'Lang="en"'),
+ ('Spanish', 'Lang="es"'),
+ ('Dutch', 'Lang="nl"'),
+ ('German', 'Lang="de"')
+ ],
+ },
+]
+template_path = os.path.join(TEMPLATE_DIR, 'html_table_from_db_records.tpl')
+print datatemplate.render(open(template_path), contexts)
View
12 examples/example_html_table_from_db_records.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+if [ '!' -e "large_table.tsv" ]
+then
+ echo 'Error: Must be executed from examples directory' >&2
+ exit 1
+fi
+
+datatemplate --tsvsql data=large_table.tsv --var field='`Metric 1 F`' --var where='Test="test1"' \
+ --json-var rows='[["1", "Model=\"model1\""], ["2", "Model=\"model2\""]]' --var corner='Model' \
+ --json-var cols='[["English", "Lang=\"en\""], ["Spanish", "Lang=\"es\""], ["Dutch", "Lang=\"nl\""], ["German", "Lang=\"de\""]]' \
+ < ../templates/html_table_from_db_records.tpl
View
12 examples/example_tex_table.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+import os.path
+import datatemplate
+
+EXAMPLE_DIR = os.path.dirname(os.path.abspath(__file__))
+TEMPLATE_DIR = os.path.join(os.path.dirname(EXAMPLE_DIR), 'templates')
+
+contexts = [
+ datatemplate.csv('data', os.path.join(EXAMPLE_DIR, 'large_table.tsv'), dialect='tab'),
+]
+template_path = os.path.join(TEMPLATE_DIR, 'tex_table.tpl')
+print datatemplate.render(open(template_path), contexts)
View
9 examples/example_tex_table.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+if [ '!' -e "large_table.tsv" ]
+then
+ echo 'Error: Must be executed from examples directory' >&2
+ exit 1
+fi
+
+datatemplate --tsv data=large_table.tsv < ../templates/tex_table.tpl
View
28 examples/example_tex_table_from_db_records.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+import os.path
+import datatemplate
+
+EXAMPLE_DIR = os.path.dirname(os.path.abspath(__file__))
+TEMPLATE_DIR = os.path.join(os.path.dirname(EXAMPLE_DIR), 'templates')
+
+contexts = [
+ datatemplate.csvsql(os.path.join(EXAMPLE_DIR, 'large_table.tsv'), dialect='tab'),
+ {
+ 'field': '`Metric 1 F`',
+ 'where': 'Test="test1"',
+ 'corner': 'Model',
+ 'rows': [
+ ('1', 'Model="model1"'),
+ ('2', 'Model="model2"'),
+ ('3', 'Model="model3"'),
+ ],
+ 'cols': [
+ ('English', 'Lang="en"'),
+ ('Spanish', 'Lang="es"'),
+ ('Dutch', 'Lang="nl"'),
+ ('German', 'Lang="de"')
+ ],
+ },
+]
+template_path = os.path.join(TEMPLATE_DIR, 'tex_table_from_db_records.tpl')
+print datatemplate.render(open(template_path), contexts)
View
12 examples/example_tex_table_from_db_records.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+if [ '!' -e "large_table.tsv" ]
+then
+ echo 'Error: Must be executed from examples directory' >&2
+ exit 1
+fi
+
+datatemplate --tsvsql data=large_table.tsv --var field='`Metric 1 F`' --var where='Test="test1"' \
+ --json-var rows='[["1", "Model=\"model1\""], ["2", "Model=\"model2\""]]' --var corner='Model' \
+ --json-var cols='[["English", "Lang=\"en\""], ["Spanish", "Lang=\"es\""], ["Dutch", "Lang=\"nl\""], ["German", "Lang=\"de\""]]' \
+ < ../templates/tex_table_from_db_records.tpl
View
72 examples/large_table.tsv
@@ -0,0 +1,72 @@
+Lang Model Test Metric 1 P Metric 1 R Metric 1 F Metric 2 P Metric 2 R Metric 2 F
+es modelx test1 78.2 77.1 77.6 86.3 85.1 85.7
+es modelx test2 79.2 79.9 79.6 87.3 88.1 87.7
+es modelx test3 53.5 54.0 53.7 70.9 71.5 71.2
+es model1 test1 57.1 55.1 56.1 73.9 71.3 72.6
+es model1 test2 60.0 58.8 59.4 75.9 74.4 75.1
+es model1 test3 89.5 87.8 88.6 94.1 92.3 93.2
+es model2 test1 57.6 57.1 57.4 73.6 73.1 73.4
+es model2 test2 59.3 58.4 58.9 75.1 74.0 74.6
+es model2 test3 83.7 83.8 83.8 90.2 90.3 90.2
+es model3 test1 60.8 60.6 60.7 75.3 75.0 75.2
+es model3 test2 61.1 61.0 61.0 75.9 75.8 75.8
+es model3 test3 83.4 83.7 83.5 90.0 90.2 90.1
+es model5 test1 62.6 62.2 62.4 76.1 75.6 75.9
+es model5 test2 63.8 63.6 63.7 77.5 77.3 77.4
+es model5 test3 82.3 82.6 82.4 89.4 89.7 89.5
+es model0 test1 55.0 54.0 54.5 72.5 71.2 71.8
+es model0 test2 57.4 56.8 57.1 74.1 73.3 73.7
+es model0 test3 88.8 87.9 88.3 93.4 92.5 92.9
+fr model3 test3 74.8 67.1 70.8 84.1 75.4 79.5
+fr model5 test3 72.7 64.3 68.3 82.8 73.1 77.7
+nl modelx test1 78.2 74.9 76.5 87.2 83.4 85.3
+nl modelx test2 79.6 77.5 78.6 87.1 84.8 85.9
+nl modelx test3 50.4 41.1 45.3 71.6 58.4 64.3
+nl model1 test1 65.3 57.9 61.4 78.0 69.2 73.4
+nl model1 test2 65.9 58.9 62.2 77.7 69.4 73.3
+nl model1 test3 94.5 86.5 90.3 96.5 88.4 92.3
+nl model2 test1 64.1 60.7 62.4 77.8 73.7 75.7
+nl model2 test2 65.3 62.7 64.0 78.4 75.3 76.8
+nl model2 test3 90.0 89.9 90.0 94.0 93.9 94.0
+nl model3 test1 64.0 60.4 62.2 78.1 73.8 75.9
+nl model3 test2 65.0 63.0 64.0 78.0 75.6 76.8
+nl model3 test3 89.7 89.6 89.6 93.9 93.8 93.8
+nl model5 test1 61.9 59.3 60.6 75.9 72.7 74.3
+nl model5 test2 64.5 62.7 63.5 76.4 74.3 75.3
+nl model5 test3 89.0 89.3 89.1 93.4 93.7 93.5
+nl model0 test1 57.2 54.7 55.9 73.3 70.1 71.7
+nl model0 test2 55.7 54.6 55.1 71.6 70.1 70.8
+nl model0 test3 81.7 79.5 80.6 89.9 87.5 88.7
+en modelz test1 69.4 61.2 65.0 80.4 70.9 75.4
+en modelz test2 65.9 57.3 61.3 77.3 67.3 72.0
+en modelz test3 52.0 49.8 50.9 69.2 66.2 67.7
+en modelx test1 89.6 89.6 89.6 93.1 93.1 93.1
+en modelx test2 84.9 85.4 85.2 89.7 90.2 89.9
+en modelx test3 55.4 54.6 55.0 69.2 68.2 68.7
+en model1 test1 67.3 61.3 64.2 79.0 71.9 75.3
+en model1 test2 60.9 56.3 58.5 74.0 68.4 71.1
+en model1 test3 83.4 82.3 82.8 90.3 89.1 89.7
+en model2 test1 69.3 65.4 67.3 80.0 75.5 77.7
+en model2 test2 61.5 59.2 60.3 73.9 71.2 72.5
+en model2 test3 81.9 82.3 82.1 88.9 89.3 89.1
+en model3 test1 69.7 66.3 67.9 79.9 76.0 77.9
+en model3 test2 62.1 60.5 61.3 74.0 72.1 73.0
+en model3 test3 82.0 82.7 82.4 88.8 89.6 89.2
+en model5 test1 68.9 66.3 67.6 79.7 76.6 78.2
+en model5 test2 59.8 58.7 59.3 73.2 71.8 72.5
+en model5 test3 80.9 81.8 81.4 88.1 89.1 88.6
+en model0 test1 54.6 55.8 55.2 68.0 69.5 68.7
+en model0 test2 49.9 51.3 50.6 64.2 66.0 65.1
+en model0 test3 74.4 76.9 75.7 83.2 86.0 84.6
+de modelx test1 75.0 55.3 63.6 83.6 61.7 71.0
+de modelx test2 76.8 58.6 66.5 84.1 64.2 72.8
+de modelx test3 55.4 39.0 45.8 69.0 48.7 57.1
+de model1 test1 60.2 53.7 56.7 71.3 63.6 67.2
+de model2 test1 62.6 55.8 59.0 73.9 65.9 69.6
+de model3 test1 64.1 57.9 60.9 74.7 67.5 70.9
+de model3 test2 57.3 54.3 55.8 68.8 65.2 66.9
+de model3 test3 90.6 90.3 90.4 93.5 93.2 93.3
+de model5 test1 64.4 59.0 61.6 75.1 68.8 71.8
+de model5 test2 57.7 55.6 56.6 69.2 66.6 67.8
+de model5 test3 83.1 81.6 82.3 88.9 87.3 88.1
+de model0 test1 56.9 50.5 53.5 68.2 60.5 64.1
Please sign in to comment.
Something went wrong with that request. Please try again.