# kme files

## createKme()

canlib.kvmlib.createKme(path, filetype=FileType.KME50)

  Create a KME file on the host computer

  Parameters

    - path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme50"`).

    - filetype (`FileType`) – The KME file type

  Returns

    `Kme`

  New in version 1.7.

## openKme()

canlib.kvmlib.openKme(path, filetype=FileType.KME50)

  Open a KME file on the host computer

  Parameters

    - path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme50"`).

    - filetype (`FileType`) – The KME file type

  Returns

    `Kme`

  New in version 1.7.

## Kme

class canlib.kvmlib.Kme(handle)

  A kme file

  A class representing a KME file. The main use is twofold:

  Either we create a KME file using `createKme` and would like to write events using `Kme.write_event`:

      with kvmlib.createKme('out/data.kme50') as kme:
          ...
          kme.write_event(my_logevent)

  Or we read events from an existing KME file:

      with kvmlib.openKme('in/data.kme50') as kme:
          event = kme.read_event()
          ...
          print(event)

  Note that only KME files of type KME50 and KME60 may currently be written to.

  New in version 1.7.

  Changed in version 1.20: Added experimental support for KME60.

  close()
  estimate_events()

    Estimate how many events the KME file contains

    > Returns:

    >   `int`: Approximate number of events in KME file.

    New in version 1.7.

    Deprecated since version 1.11.

  event_count_estimation()

    Returns an approximation of the number of events contained in the KME file.

    > Returns:

    >   `int`: Approximate number of events in KME file.

    New in version 1.11.

  events()
  read_event()

    Read logevent from KME file

    > Returns:

    >   `memoLogEventEx`

    New in version 1.7.

  write_event(logevent)

## kme_file_type()

canlib.kvmlib.kme_file_type(path)

  Scan KME file and report version

  Open and read the file `path` and try to decode what version of KME it contains.

  Parameters

    path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme"`).

  Returns

    `FileType` – The KME file type

  New in version 1.7.