-
Notifications
You must be signed in to change notification settings - Fork 36
Bilara io
Bilara IO refers to a utility that lives in the .scripts/bilara-io
folder. It requires Python 3.6 or higher (see dependencies).
sheet_export.py
exports data from the json to a spreadsheet file.
sheet_import.py
imports data from a spreadsheet file to json.
Both utilities have help available by calling them with the --help
argument.
In general sheet_import.py
expects to take a file that has been produced by sheet_export.py
and it will update the files.
- Make sure the bilara-data repo exists and is updated on the
unpublished
branch. - Create a
tsv
file from any text definable with a UID on SuttaCentral. Here it is Udana:./sheet_export.py ud ud.tsv
- Make changes in a text editor, and/or import into a spreadsheet.
- When ready, save and import:
./sheet_import.py ud.tsv
It is also possible to run sheet-import.py
in create mode, which creates new files. In this case it needs to be told at what path to create the file or files, this can be done using a config file which will look something like this:
{
"muids": {
"comment": "comment",
"html": "html",
"root": "root-san"
},
"paths": {
"comment": "comment/en/",
"html": "html/san/sf/",
"root": "root/san/sf/"
}
}
muids defines the suffix of the file, which will be joined with the uid from the filename. The paths define the subfolders within the repo.
For convenience and consistency, it's possible to store configuration in the bilara-io/config
folder, and when the -c/--create
flag is used but a --config
flag is not used, it will look in the config folder for a config file that matches the filename. For example if you are importing a spreadsheet sf276.tsv
it would look for a config called either sf276.json
or sf.json
. Storing the config will help to maintain consistency. It is also possible to explicitly define the config file using the --config
flag.
Example command:
./sheet_import.py sf276.tsv -c
Bilara IO requires Python >= 3.6 and has no library dependencies for working with .csv and .tsv files.
Many operating systems will now have at least Python 3.6 installed by default. Otherwise use a python environment manager such as pyenv.
To import/export in formats other than .csv or .tsv requires that pyexcel be installed, along with its dependencies for the desired file format. For example to work with .odt files would require running something like:
pip3 install pyexcel pyexcel-ods3