# Specifying data for analysis

We introduce the concept of a “data store”. This represents the data record(s) that you want to analyse. It can be a single file, a directory of files, a zipped directory of files or a single `tinydb` file containing multiple data records.

We represent this concept by a `DataStore` class. There are different flavours of these:

- directory based

- zip archive based

- TinyDB based (this is a NoSQL json based data base)

These can be read only or writable. All of these types support being indexed, iterated over, filtered, etc.. The `tinydb` variants do have some unique abilities (discussed below).

## A read only data store

To create one of these, you provide a `path` AND a `suffix` of the files within the directory / zip that you will be analysing. (If the path ends with `.tinydb`, no file suffix is required.)

## Data store “members”

These are able to read their own raw data.

## Showing the last few members

Use the `head()` method to see the first few.

## Filtering a data store for specific members

## Looping over a data store

## Making a writeable data store

The creation of a writeable data store is handled for you by the different writers we provide under `cogent3.app.io`.

Warning

The `WritableZippedDataStore` is deprecated.

## TinyDB data stores are special

When you specify a TinyDB data store as your output (by using `io.write_db()`), you get additional features that are useful for dissecting the results of an analysis.

One important issue to note is the process which creates a TinyDB “locks” the file. If that process exits unnaturally (e.g. the run that was producing it was interrupted) then the file may remain in a locked state. If the db is in this state, `cogent3` will not modify it unless you explicitly unlock it.

This is represented in the display as shown below.

To unlock, you execute the following:

### Interrogating run logs

If you use the `apply_to(logger=true)` method, a `scitrack` logfile will be included in the data store. This includes useful information regarding the run conditions that produced the contents of the data store.

Log files can be accessed vial a special attribute.

Each element in that list is a `DataStoreMember` which you can use to get the data contents.