import csv


def read_traces_csv(filename):
  """Read a .csv file containing deduplicated logic analyser traces.

  The file should contain two columns: nanosecond start time and byte value.
  The byte value should be assumed to persist on the bus until the start time
  in the next record.

  Args:
    filename: .csv file to read.

  Returns:
    A list of (start time, byte value) tuples.
  """
  traces = []
  with open(filename) as f:
    for timestamp, byte in csv.reader(f):
      traces.append((int(timestamp), byte))
  return traces