Skip to content

Instantly share code, notes, and snippets.

@mgwilliams
Created January 31, 2014 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgwilliams/8738878 to your computer and use it in GitHub Desktop.
Save mgwilliams/8738878 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
'''
Special CSV outputter for grains ;-)
'''
# Define the module's virtual name
__virtualname__ = 'csv'
def __virtual__():
return __virtualname__
def output(grains):
'''
Output the grains in a "special" way
'''
ret = ''
for id_, minion in grains.items():
for key in sorted(minion):
ret += '{0},{1},"{2}"\n'.format(id_, key, minion[key])
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment