Skip to content

Commit 0cf48a0

Browse files
authored
Merge branch 'master' into 356-end-to-end-tests
2 parents 3985503 + e379634 commit 0cf48a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1017
-157
lines changed

docs/flatten.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ CSV files for you, populated with the data from the input JSON file.
5858
.. csv-table:: sheet: tab_dish.csv
5959
:file: ../examples/flatten/simple/expected/tab_dish.csv
6060

61-
.. csv-table:: sheet: dish.csv
62-
:file: ../examples/flatten/simple/expected/dish.csv
63-
:header-rows: 1
64-
6561
.. caution ::
6662
6763
If you forget the `--root-list-path` option and your data isn't under a top

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Contents:
4141
developerguide
4242
usage-ocds
4343
usage-360
44+
usage-iati
4445

4546
Get started by reading the Spreadsheet Designer's Guide to understand the core
4647
concepts, how to use the `flatten-tool` command and how to structure your own

docs/unflatten.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,61 @@ table" section earlier.
11791179
titles, you can use the schema in the "Arbitrary-depth in a single
11801180
table" section too.
11811181
1182+
Metadata Tab
1183+
============
1184+
1185+
Flattentool supports naming of a special sheetname (or Tab) in a spreadsheet to add data to the top level of the returned data structure. Currently it only supports output format JSON and the input format has to be XLSX.
1186+
1187+
Example Usage
1188+
-------------
1189+
1190+
You have a spreadsheet named "mydata.xlsx with" 2 sheets. The first sheet named "Cafe":
1191+
1192+
.. csv-table::
1193+
:header-rows: 1
1194+
:file: ../examples/cafe/meta-tab/data.csv
1195+
1196+
A second sheet you would like to add some metadata to this list of rows to a sheet named "Meta":
1197+
1198+
.. csv-table::
1199+
:file: ../examples/cafe/meta-tab/metadata.csv
1200+
1201+
As you can see it is also possible to choose to have the metadata headings on the first column (not the first row) with metadata vertical.
1202+
1203+
The command for doing this:
1204+
1205+
.. literalinclude:: ../examples/cafe/meta-tab/cmd.txt
1206+
:language: bash
1207+
1208+
.. literalinclude:: ../examples/cafe/meta-tab/expected.json
1209+
:language: json
1210+
1211+
Options
1212+
-------
1213+
1214+
`--metatab-name`
1215+
1216+
This is the name of the sheet with the metadata on. It is case sensitive. It is the only mandatory option if you want to parse a metatab, without it no metatab will be parsed
1217+
1218+
`--metatab-schema`
1219+
1220+
The JSON schema of the metatab. This schema will be used to determine the types and/or titles of the data in the metatab. It works in the same way as the --schema option but just for the metatab. The schema used with the --schema option has no effect on the metatab parsing, so this has to be specified if you need title handling or want to specify types.
1221+
1222+
`--metatab-only`
1223+
1224+
Just return the metatab information and not the rest of the doc. Using the example above:
1225+
1226+
.. literalinclude:: ../examples/cafe/meta-tab-only/cmd.txt
1227+
:language: bash
1228+
1229+
.. literalinclude:: ../examples/cafe/meta-tab-only/expected.json
1230+
:language: json
1231+
1232+
`--metatab-vertical-orientation`
1233+
1234+
Say that the metatab data runs vertically rather that horizontally see example above.
1235+
1236+
11821237
Source maps
11831238
===========
11841239

docs/usage-iati.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Flatten-Tool for IATI
2+
=====================
3+
4+
Currently flatten-tool only supports Spreadsheet->XML for IATI (unflatten), not conversion in the other direction, or automated template creation.
5+
6+
Convert a spreadsheet to XML
7+
----------------------------
8+
9+
For an xlsx file called ``filename.xlsx``:
10+
11+
.. code-block:: bash
12+
13+
flatten-tool unflatten --xml --id-name iati-identifier --root-list-path iati-activity -o iati.xml -f xlsx filename.xlsx
14+
15+
16+
For a directory of csv files called ``csv_directory``:
17+
18+
.. code-block:: bash
19+
20+
flatten-tool unflatten --xml --id-name iati-identifier --root-list-path iati-activity -o iati.xml -f csv csv_directory
21+
22+
(Outputs a file called ``iati.xml``).
23+
24+
25+
Example
26+
-------
27+
28+
Given these two sheets:
29+
30+
.. csv-table:: sheet: main.csv
31+
:file: ../examples/iati/main.csv
32+
33+
.. csv-table:: sheet: transactions.csv
34+
:file: ../examples/iati/transactions.csv
35+
36+
Running this command:
37+
38+
.. literalinclude:: ../examples/iati/cmd.txt
39+
:language: bash
40+
41+
Produces this XML:
42+
43+
.. literalinclude:: ../examples/iati/expected.xml
44+
:language: xml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool unflatten --input-format=xlsx --metatab-only --metatab-name Meta --metatab-vertical-orientation examples/cafe/meta-tab-only/meta-tab.xlsx
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name,address
2+
Healthy Cafe,"123 City Street, London"
3+
Vegetarian Cafe,"42 Town Road, Bristol"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dataLicense": "CC",
3+
"rowCount": "2",
4+
"publishedDate": "2001-01-01"
5+
}
5.89 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dataLicense,CC
2+
rowCount,2
3+
publishedDate,2001-01-01

examples/cafe/meta-tab/cmd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool unflatten --input-format=xlsx --metatab-name Meta --metatab-vertical-orientation examples/cafe/meta-tab/meta-tab.xlsx

0 commit comments

Comments
 (0)