Standard location_provider class(es) for creating DataSet locations.

class qcodes.data.location.FormatLocation(fmt=None, fmt_date=None, fmt_time=None, fmt_counter=None, record=None)[source]

Bases: object

This is the default DataSet Location provider.

It provides a callable that returns a new (not used by another DataSet) location string, based on a format string fmt and a dict record of information to pass to fmt.

Default record items are date, time, and counter Record item priority from lowest to highest (double items will be overwritten):

  • current date, and time

  • record dict from __init__

  • record dict from __call__

  • automatic counter

For example if any record dict contains a date keyword, it will no longer be auto-generated.

Uses io.list to search for existing data at a matching location.

counter must NOT be provided in the record. If fmt contains ‘{counter}’, we look for existing files matching everything BEFORE this, then find the highest counter (integer) among those files and use the next value.

If the format string does not contain {counter} but the location we would return is occupied, we add '_{counter}' to the end.


loc_provider = FormatLocation(
loc = loc_provider(DiskIO('.'),
                   record={'name': 'Rainbow', 'label': 'test'})
> '2016-04-30/#001_13-28-15_Rainbow_test'
  • fmt (Optional[str]) – a format string that all the other info will be inserted into. Default ‘{date}/{time}’, or ‘{date}/{time}_{name}’ if there is a name in the record.

  • fmt_date (Optional[str]) – a datetime.strftime format string, should only use the date part. The result will be inserted in ‘{date}’ in fmt. Default ‘%Y-%m-%d’.

  • fmt_time (Optional[str]) – a datetime.strftime format string, should only use the time part. The result will be inserted in ‘{time}’ in fmt. Default ‘%H-%M-%S’.

  • fmt_counter (Optional[str]) – a format string for the counter (integer) which is automatically generated from existing DataSets that the io manager can see. Default ‘{03}’.

  • record (Optional[dict]) – A dict of default values to provide when calling the location_provider. Values provided later will override these values.


Do not include date/time or number formatting in fmt itself, such as ‘{date:%Y-%m-%d}’ or ‘{counter:03}’

default_fmt = 'data/{date}/#{counter}_{name}_{time}'
__call__(io, record=None)[source]

Call the location provider to get a new location.

  • io (io_manager) – where we intend to put the new DataSet.

  • record (Optional[dict]) – information to insert in the format string Any key provided here will override the default record

class qcodes.data.location.SafeFormatter[source]

Bases: string.Formatter

Modified string formatter that doesn’t complain about missing keys.

get_value(key, args, kwargs)[source]

Missing keys just get left as they were: ‘{key}’.

check_unused_args(used_args, args, kwargs)
convert_field(value, conversion)
format_field(value, format_spec)
get_field(field_name, args, kwargs)
vformat(format_string, args, kwargs)