nodes: 0, module; 1, function_definition; 2, function_name:csv; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:d; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, function_definition; 13, comment:# noinspection PyBroadException; 14, function_definition; 15, if_statement; 16, if_statement; 17, if_statement; 18, expression_statement; 19, expression_statement; 20, for_statement; 21, expression_statement; 22, for_statement; 23, return_statement; 24, identifier:order; 25, None; 26, identifier:header; 27, None; 28, identifier:sort_keys; 29, True; 30, comment:"""
          prints a table in csv format
  
          :param d: A a dict with dicts of the same type.
          :type d: dict
          :param order:The order in which the columns are printed.
                      The order is specified by the key names of the dict.
          :type order:
          :param header: The Header of each of the columns
          :type header: list or tuple of field names
          :param sort_keys: TODO: not yet implemented
          :type sort_keys: bool
          :return: a string representing the table in csv format
          """; 31, assignment; 32, function_name:_keys; 33, parameters; 34, block; 35, function_name:_get; 36, parameters; 37, block; 38, boolean_operator; 39, block; 40, comparison_operator:order is None; 41, block; 42, boolean_operator; 43, block; 44, elif_clause; 45, assignment; 46, assignment; 47, identifier:attribute; 48, identifier:order; 49, block; 50, assignment; 51, identifier:job; 52, identifier:d; 53, block; 54, identifier:table; 55, identifier:first_element; 56, subscript; 57, return_statement; 58, identifier:element; 59, identifier:key; 60, try_statement; 61, return_statement; 62, comparison_operator:d is None; 63, comparison_operator:d == {}; 64, return_statement; 65, identifier:order; 66, None; 67, expression_statement; 68, comparison_operator:header is None; 69, comparison_operator:order is not None; 70, expression_statement; 71, comparison_operator:header is None; 72, block; 73, identifier:table; 74, string:""; 75, identifier:content; 76, list; 77, expression_statement; 78, identifier:table; 79, binary_operator:table + ",".join([str(e) for e in content]) + "\n"; 80, expression_statement; 81, for_statement; 82, expression_statement; 83, call; 84, integer:0; 85, call; 86, block; 87, except_clause; 88, identifier:tmp; 89, identifier:d; 90, None; 91, identifier:d; 92, dictionary; 93, None; 94, assignment; 95, identifier:header; 96, None; 97, identifier:order; 98, None; 99, assignment; 100, identifier:header; 101, None; 102, expression_statement; 103, call; 104, binary_operator:table + ",".join([str(e) for e in content]); 105, string:"\n"; 106, assignment; 107, identifier:attribute; 108, identifier:order; 109, block; 110, assignment; 111, identifier:list; 112, argument_list; 113, identifier:list; 114, argument_list; 115, expression_statement; 116, block; 117, identifier:order; 118, call; 119, identifier:header; 120, identifier:order; 121, assignment; 122, attribute; 123, argument_list; 124, identifier:table; 125, call; 126, identifier:content; 127, list; 128, try_statement; 129, identifier:table; 130, binary_operator:table + ",".join([str(e) for e in content]) + "\n"; 131, identifier:d; 132, subscript; 133, assignment; 134, expression_statement; 135, identifier:_keys; 136, argument_list; 137, identifier:header; 138, call; 139, identifier:content; 140, identifier:append; 141, identifier:attribute; 142, attribute; 143, argument_list; 144, block; 145, except_clause; 146, binary_operator:table + ",".join([str(e) for e in content]); 147, string:"\n"; 148, identifier:d; 149, identifier:first_element; 150, identifier:tmp; 151, call; 152, assignment; 153, identifier:_keys; 154, argument_list; 155, string:","; 156, identifier:join; 157, list_comprehension; 158, expression_statement; 159, block; 160, identifier:table; 161, call; 162, identifier:str; 163, argument_list; 164, identifier:tmp; 165, string; 166, call; 167, for_in_clause; 168, call; 169, expression_statement; 170, attribute; 171, argument_list; 172, subscript; 173, string_content:; 174, identifier:str; 175, argument_list; 176, identifier:e; 177, identifier:content; 178, attribute; 179, argument_list; 180, call; 181, string:","; 182, identifier:join; 183, list_comprehension; 184, subscript; 185, identifier:key; 186, identifier:e; 187, identifier:content; 188, identifier:append; 189, subscript; 190, attribute; 191, argument_list; 192, call; 193, for_in_clause; 194, identifier:d; 195, identifier:element; 196, subscript; 197, identifier:attribute; 198, identifier:content; 199, identifier:append; 200, string:"None"; 201, identifier:str; 202, argument_list; 203, identifier:e; 204, identifier:content; 205, identifier:d; 206, identifier:job; 207, identifier:e
code: def csv(cls,
              d,
              order=None,
              header=None,
              sort_keys=True):
          """
          prints a table in csv format
  
          :param d: A a dict with dicts of the same type.
          :type d: dict
          :param order:The order in which the columns are printed.
                      The order is specified by the key names of the dict.
          :type order:
          :param header: The Header of each of the columns
          :type header: list or tuple of field names
          :param sort_keys: TODO: not yet implemented
          :type sort_keys: bool
          :return: a string representing the table in csv format
          """
          first_element = list(d)[0]
  
          def _keys():
              return list(d[first_element])
  
          # noinspection PyBroadException
          def _get(element, key):
              try:
                  tmp = str(d[element][key])
              except:
                  tmp = ' '
              return tmp
  
          if d is None or d == {}:
              return None
  
          if order is None:
              order = _keys()
  
          if header is None and order is not None:
              header = order
          elif header is None:
              header = _keys()
  
          table = ""
          content = []
          for attribute in order:
              content.append(attribute)
          table = table + ",".join([str(e) for e in content]) + "\n"
  
          for job in d:
              content = []
              for attribute in order:
                  try:
                      content.append(d[job][attribute])
                  except:
                      content.append("None")
              table = table + ",".join([str(e) for e in content]) + "\n"
          return table