CSV import and export
The columns of a lexicon or inventory file, and how Lemula reads and writes them.
A lexicon or an inventory goes in and out of Lemula as a CSV file, with one row per entry or sound under a header row of keys. The import reads an exported file back as the same list. A file saved by a spreadsheet or written by hand follows the rules below.
The file
The first row is the header. Each of its cells names a column: form, sound, or a feature or an inventory column by its key or its name. The Features screen shows each key beside its name.
Keys are read in lower case, so Form and FORM both name the form column. Names are read in any case too: with a feature keyed pos and named Part of speech, both pos and part of speech fill that feature. A cell that is one column's key and another's name stands for the column of that key. Cells can be separated by commas, semicolons or tabs. Lemula takes the separator the header row uses most, and a comma when it uses none.
A cell in double quotes can hold separators, line breaks and quotes. Write each quote inside it twice: "". Every row has as many cells as the header, and blank lines are left out.
Save the file as UTF-8, or the IPA in it arrives garbled. The export separates cells with commas and writes UTF-8 with a byte order mark, which tells Excel the encoding.
Lexicon files
A lexicon file has these columns:
form: the form in IPA. Every file needs this column.written:latinand the like: the written spelling of the entry in each orthography the lexicon or the stages it is attached to are written in. An empty cell writes none, so the word keeps the spelling it carries. A cell holding only-spells the word by the orthography's rows from the entry's stage on, and''-writes the spelling-itself. A column of an orthography the lexicon isn't written in is not imported.spelling:latinand the like, each after itswritten:column: the spelling the lexicon shows for the entry. That is its written spelling, the spelling its word carries from an earlier stage, or its form as the orthography's rows spell it. The import reads past these columns, so an exported file reads back unchanged and no spelling turns into a written one on the way.word: the word an entry is about, for an entry that names one. The export writes it so that such an entry reads back unchanged. A file you write yourself can leave it empty, because an entry finds its words by its features. Two rows can't name the same word.- The key or name of a feature, such as
glossorpos: the entry's value for that feature.
The export writes the columns in that order, with the features in the order the Features screen lists them. A lexicon of an empty project comes out like this:
form,word,gloss,pos,translation
ˈluna,,moon | month,noun,moon
ˈsol,,sun,noun,sunThe export writes the entries as last saved, in the order the lexicon holds them. Edits you haven't saved stay out of the file, and so does a sort in the grid, because an import stores a file's rows in the order they come.
An import replaces every entry of the lexicon, and a line that starts from the lexicon gets the file's entries as its starting words. Import from CSV waits for your edits to save, and is disabled while an edit can't be saved. Before anything is written, the import dialog shows what each key is imported as, and lists the letters of written spellings that no row of their orthography writes. Those spellings are imported as written.
Inventory files
An inventory file has these columns:
sound: the sound in IPA. Every file needs this column.- The key or name of an inventory column: the sound's value in that column. A yes-or-no column takes
yesornoin lower case, or an empty cell.
A column named IPA description is not imported: each sound's description comes from its symbol.
The export writes the list as the grid shows it, unsaved edits included.
An import replaces the list with the file's sounds, and the list saves them a second later. A sound the list already has keeps its values in the columns the file leaves out, and an empty cell clears its value in that column. A sound matches only when the file writes it the same way, so g and ɡ are two sounds here.
Where the file leaves out sounds the list has, or its empty cells clear values, Lemula asks first. The question names the sounds removed, or the first eight and how many more, and the values cleared in each column. A file that only adds sounds and changes values is imported at once, and Undo in the notice puts the list back.
Several values in one cell
A feature that takes several values, such as a gloss, holds them in one cell separated by |. Spaces around each value are dropped, and so are empty values. To keep a | inside a value, write \|. To keep a backslash, write \\. A backslash before any other character stays as written.
moon | monthholdsmoonandmonth.moon || monthholds the same two values.either\|orholds one value,either|or.a\\bholds one value,a\b.
The export writes several values the same way. A feature that takes one value reads the whole cell as written, | and backslashes included. Inventory columns take one value each.
The lexicon grid, the entry form and the bulk edit dialog read | the same way, so moon | month typed into a gloss is two values there too.
Columns and values the project lacks
A lexicon file can bring a column that names no feature by key or name, or a value that a fixed list doesn't name. The import dialog lists both and asks what to do with them:
- Add to features: each new column becomes a free-text feature named by its header, and each rejected value joins its list. The feature's key comes from the name, as on the Features screen:
Word classgets the keyword-class, orword-class-2when a feature already has that key. - Discard unfamiliar data: the entries are imported without the new columns and the rejected values.
A new column becomes a feature with several values when one of its cells holds a | not written as \|, and a feature with one value otherwise. A value that a suggested list lacks is imported as written either way, and the list stays as it is.
An inventory file can bring a column the project has no inventory column for. The import asks whether to read the file with the column or without it, in the same question that names what the file removes. An added column is named by its header and keyed the way a feature is. It is a yes-or-no column when each filled cell in it says yes or no, and a text column otherwise. Added columns join every inventory of the project when the list saves.
Cells that start with =, +, - or @
A spreadsheet runs a cell that starts with =, +, - or @ as a formula. The export writes an apostrophe before such a cell so that a spreadsheet doesn't run it: a suffix like -ment comes out as '-ment.
The import takes one apostrophe off before these characters, whoever wrote the file. An exported file edited in a spreadsheet and saved again reads back as it was. In a file you write by hand:
-mentreads as-ment.'-mentreads as-ment, and'-in awritten:column as-.''=xreads as'=x. Double the apostrophe to keep one.'kasareads as'kasa, since no formula character follows the apostrophe.
Skipped rows and refused files
A lexicon import skips a row with no form and lists it by line in the import dialog. A row with only a form is imported, and its gloss can come later. An inventory import skips a row with no sound, and the message after the import names its line. The rest of the file is imported in both cases.
These refuse the whole file, and the message names the line:
- the header has an empty key, or the same key twice in any case;
- two columns name the same feature or inventory column, by key or by name, or two new columns have the same name;
- a lexicon file has no
formcolumn, or an inventory file nosoundcolumn; - a row has more or fewer cells than the header;
- a quote opens in the middle of an unquoted cell, text follows a closing quote, or a quoted cell is never closed;
- two rows of a lexicon file name the same word;
- a yes-or-no column of an inventory file holds something other than
yesorno.
A file that gives no entry or no sound is refused as well, because importing it would only empty the list.
Entry limit
Your plan sets the most entries a lexicon can hold. A file that gives more is refused, and the import dialog says how many entries to remove. The count leaves out skipped rows. A file with more than 1,000 rows over the limit is refused, skipped rows included. Inventories have no such limit. Plans lists the limits of each plan.