Skip to content

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 is a key that names a column: form, sound, or the key of a feature or an inventory column. The Features screen shows each key beside its name.

Keys are read in lower case, so Form and FORM both name the form column. 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.
  • spelling:latin and the like: the form spelled in each orthography the lexicon is written in. The import skips these columns, since a spelling is read off the form.
  • 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 of a feature, such as gloss or pos: 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 a new project comes out like this:

form,word,gloss,pos,translation
ˈluna,,moon | month,noun,moon
ˈsol,,sun,noun,sun

The export writes the entries as last saved. Edits you haven't saved stay out of the file.

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. Save or revert your edits first: Import from CSV is disabled while the lexicon has unsaved edits. Before anything is written, the import dialog shows what each key is imported as.

Inventory files

An inventory file has these columns:

  • sound: the sound in IPA. Every file needs this column.
  • The key of an inventory column: the sound's value in that column. A yes-or-no column takes yes or no in lower case, or an empty cell.

The export writes the list as the grid shows it, unsaved edits included.

An import replaces the list with the file's sounds. They arrive as unsaved edits, and Save keeps them. A sound the list already has keeps its values in the columns the file leaves out.

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 | month holds moon and month.
  • moon || month holds the same two values.
  • either\|or holds one value, either|or.
  • a\\b holds 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 whose key no feature has, 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 key, and each rejected value joins its list.
  • 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 add the column or discard it. An added column 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 you save.

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:

  • -ment reads as -ment.
  • '-ment reads as -ment.
  • ''=x reads as '=x. Double the apostrophe to keep one.
  • 'kasa reads as 'kasa, since no formula character follows the apostrophe.

Skipped rows and refused files

A lexicon import skips these rows and lists them by line in the import dialog:

  • a row with no form;
  • a row with a form and no word or feature value, since an entry needs one of them to say which word it is about;
  • with Discard unfamiliar data, a row whose only values were discarded.

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;
  • a lexicon file has no form column, or an inventory file no sound column;
  • 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 yes or no.

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. Inventories have no such limit. Plans lists the limits of each plan.