File input and output

CSV files

taxonome.taxa.file_csv.iter_individuals(filehandle, namefield='Name', authfield='Author', progress=None, **kwargs)

Read individuals from a CSV file - i.e. the same name may appear on more than one row.

Yields pairs of name, info

taxonome.taxa.file_csv.iter_synonyms(filehandle, synnamefield='Name', synauthfield='Author', accnamefield='Accname', accauthfield='Accauthor', progress=None, *args, **kwargs)

Loads a set of synonyms from a CSV file. Yields triples of (synonym, accepted name, other fields dict).

*field parameters work like load_taxa.

taxonome.taxa.file_csv.iter_taxa(filehandle, namefield='Name', authfield='Author', progress=None, tracker=None, *args, **kwargs)

Load taxa iteratively from a CSV file. It expects fields for name and author to be present, describing the taxa to use. Other fields will be stored as a dictionary in each taxon’s .info property.

If authfield is set to True, it will attempt to parse names in the namefield to names and authorities. If authfield is None, no authfield will be used.

progress is an object used by the GUI to track progress. It is called periodically with the number of bytes read.

Any other arguments are passed to the csv.DictReader object–see Python’s documentation.

taxonome.taxa.file_csv.load_individuals(filehandle, namefield='Name', authfield='Author', **kwargs)

Load a TaxonSet representing the individuals in the CSV file. Each name may appear on several rows.

taxonome.taxa.file_csv.load_synonyms(filehandle, synnamefield='Name', synauthfield='Author', accnamefield='Accname', accauthfield='Accauthor', get_info=True, *args, **kwargs)

Loads a set of synonyms from a CSV file. Returns a TaxonSet containing the taxa.

*field parameters work like load_taxa.

If get_info is True (the default), extra info from the lines with the accepted names is attached to the taxa.

taxonome.taxa.file_csv.load_taxa(filehandle, namefield='Name', authfield='Author', *args, **kwargs)

Load a TaxonSet from a CSV file. It expects fields for name and author to be present, describing the taxa to use. Other fields will be stored as a dictionary in each taxon’s .info property.

Any other arguments are passed to the csv.DictReader object–see Python’s documentation.

taxonome.taxa.file_csv.save_individuals(filehandle, taxonset, namefield='Name', authfield='Author', **kwargs)

Save records of individuals (e.g. specimens, sightings) from a TaxonSet.

This requires a collection which can be iterated more than once.

taxonome.taxa.file_csv.save_synonyms(filehandle, taxonset, snamefield='Name', sauthfield='Author', accnamefield='Accname', accauthfield='Accauthor', include_accepted_names=True, *args, **kwargs)

Writes a set of synonyms to a CSV file. (This only uses the synonyms in the .othernames property of each Taxon, not the names in the TaxonSet’s index.

taxonome.taxa.file_csv.save_taxa(filehandle, taxonset, namefield='Name', authfield='Author', info_fields=, []write_distribution=False, *args, **kwargs)

Writes a TaxonSet to a CSV file. Accepted name and author will be recorded, along with any fields specified from .info.

If info_fields is True, all fields will be saved. If write_distribution is None, distribution will be saved if any data is present. Both of these options need a collection of taxa which can be iterated over more than once.

JSONlines files

This modules is for loading and saving taxa in the JSON lines format. This is a modification of JSON where a series of JSON items are stored line by lines, allowing them to be decoded individually, without having to hold the entire object in memory.

taxonome.taxa.file_jsonlines.iter_taxa(filehandle, progress=None)

Loads taxa from a JSON lines file, iterating over them, without keeping the entire set in memory.

taxonome.taxa.file_jsonlines.load_taxa(filehandle, progress=None)

Load a TaxonSet from a JSON lines file.

taxonome.taxa.file_jsonlines.save_taxa(filehandle, taxasource)

Saves a TaxonSet (or any iterable source of taxa) to the given handle, in JSON lines format.

taxonome.taxa.file_jsonlines.save_taxon(filehandle, taxon)

Saves a single taxon to the given file. Can be called repeatedly to save successive taxa.

Table Of Contents

Previous topic

Regions

Next topic

Grass species photosynthetic type

This Page