parameters: (col_obj,user,fields=[],limit=0,skip=0,sort=[],query={})
docstring: Runs query and returns items in CSV format with fields as row headers
  
      :param col_obj: MongoEngine collection object (Required)
      :type col_obj: :class:`crits.core.crits_mongoengine.CritsDocument`
      :param user: CRITs user (Required)
      :type user: str
      :param fields: Fields to return in the CSV
      :type fields: list
      :param limit: Limit on returned rows
      :type limit: int
      :param skip: Number of rows to skip
      :type skip: int
      :param sort: Fields to sort by (Prepend field name with '-' to reverse sort)
      :type sort: list
      :param query: MongoDB query
      :type query: dict
docstring_summary: Runs query and returns items in CSV format with fields as row headers
docstring_tokens: Runs query and returns items in CSV format with fields as row headers
function: def csv_query(col_obj,user,fields=[],limit=0,skip=0,sort=[],query={}):
      """
      Runs query and returns items in CSV format with fields as row headers
  
      :param col_obj: MongoEngine collection object (Required)
      :type col_obj: :class:`crits.core.crits_mongoengine.CritsDocument`
      :param user: CRITs user (Required)
      :type user: str
      :param fields: Fields to return in the CSV
      :type fields: list
      :param limit: Limit on returned rows
      :type limit: int
      :param skip: Number of rows to skip
      :type skip: int
      :param sort: Fields to sort by (Prepend field name with '-' to reverse sort)
      :type sort: list
      :param query: MongoDB query
      :type query: dict
      """
  
      # Use maximum row count from config if an invalid value is given
      crits_config = CRITsConfig.objects().first()
      if crits_config:
          csv_max = crits_config.csv_max
      else:
          csv_max = 25000 # Arbitrary Default
      if not isinstance(limit, int) or limit < 1 or limit > csv_max:
          limit = csv_max
  
      results = data_query(col_obj, user=user, limit=limit,
                                skip=skip, sort=sort, query=query,
                                projection=fields)
      if results['result'] == "OK":
          return results['data'].to_csv(fields)
      else:
          return results['msg']
function_tokens: def csv_query ( col_obj , user , fields = [ ] , limit = 0 , skip = 0 , sort = [ ] , query = { } ) : # Use maximum row count from config if an invalid value is given crits_config = CRITsConfig . objects ( ) . first ( ) if crits_config : csv_max = crits_config . csv_max else : csv_max = 25000 # Arbitrary Default if not isinstance ( limit , int ) or limit < 1 or limit > csv_max : limit = csv_max results = data_query ( col_obj , user = user , limit = limit , skip = skip , sort = sort , query = query , projection = fields ) if results [ 'result' ] == "OK" : return results [ 'data' ] . to_csv ( fields ) else : return results [ 'msg' ]