docs: def results_to_csv(network, args, pf_solution=None):
      """ Function the writes the calaculation results
      in csv-files in the desired directory. 
  
      Parameters
      ----------
      network : :class:`pypsa.Network
          Overall container of PyPSA
      args: dict
          Contains calculation settings of appl.py
      pf_solution: pandas.Dataframe or None
          If pf was calculated, df containing information of convergence else None. 
  
      """
  
      path = args['csv_export']
  
      if path == False:
          return None
  
      if not os.path.exists(path):
          os.makedirs(path, exist_ok=True)
  
      network.export_to_csv_folder(path)
      data = pd.read_csv(os.path.join(path, 'network.csv'))
      data['time'] = network.results['Solver'].Time
      data = data.apply(_enumerate_row, axis=1)
      data.to_csv(os.path.join(path, 'network.csv'), index=False)
  
      with open(os.path.join(path, 'args.json'), 'w') as fp:
          json.dump(args, fp)
  
      if not isinstance(pf_solution, type(None)):
          pf_solution.to_csv(os.path.join(path, 'pf_solution.csv'), index=True)
  
      if hasattr(network, 'Z'):
          file = [i for i in os.listdir(
              path.strip('0123456789')) if i == 'Z.csv']
          if file:
              print('Z already calculated')
          else:
              network.Z.to_csv(path.strip('0123456789') + '/Z.csv', index=False)
  
      return