def _unzip_and_make_csv(zipped):
  """Unzip options and bitmaps and make comma-separated strings from them.

  Args:
    zipped: list of tuples [(options, bitmap), ...].

  Returns:
    (options, bitmaps) - a tuple of strings or a tuple of string and None.

  bitmaps is None if every bitmap in zipped is None (meaning no bitmap was
  stored in the db) or zipped has zero length.
  """
  options_new, bitmaps_new = zip(*zipped) if zipped else ([], [])

  options_new = ",".join(options_new)
  if not bitmaps_new or not any(bitmaps_new):
    # no bitmaps were defined
    bitmaps_new = None
  else:
    bitmaps_new = ",".join(bitmaps_new)
  return options_new, bitmaps_new