# kme files

## createKme()

`canlib.kvmlib.``createKme`(path, filetype=<FileType.KME50: 3>)

  Create a KME file on the host computer

  Parameters: | path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme50"`). filetype (`canlib.kvmlib.FileType`) – The KME file type
  Returns: | `canlib.kvmlib.Kme`

  New in version 1.7.

## openKme()

`canlib.kvmlib.``openKme`(path, filetype=<FileType.KME50: 3>)

  Open a KME file on the host computer

  Parameters: | path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme50"`). filetype (`canlib.kvmlib.FileType`) – The KME file type
  Returns: | `canlib.kvmlib.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 `canlib.kvmlib.createKme` and would like to write events using `canlib.kvmlib.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 may currently be written to.

  New in version 1.7.

  `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:
    >   `kvmlib.events. 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. Returns type as kvmFILE_xxx.

  Parameters: | path (`str`) – The full filepath for the .KME file (e.g. `"data/mylog.kme"`).
  Returns: | `canlib.kvmlib.FileType` – The KME file type

  New in version 1.7.