docs: def write_flows_to_csv(self, path_to_output_file,
                             river_index=None,
                             river_id=None,
                             date_search_start=None,
                             date_search_end=None,
                             daily=False,
                             filter_mode="mean"):
          """
          Write out RAPID output to CSV file.
  
          .. note:: Need either *reach_id* or *reach_index* parameter,
                    but either can be used.
  
          Parameters
          ----------
          path_to_output_file: str
              Path to the output csv file.
          river_index: :obj:`datetime.datetime`, optional
              This is the index of the river in the file you want the
              streamflow for.
          river_id: :obj:`datetime.datetime`, optional
              This is the river ID that you want the streamflow for.
          date_search_start: :obj:`datetime.datetime`, optional
              This is a datetime object with the date of the minimum date
              for starting.
          date_search_end: :obj:`datetime.datetime`, optional
              This is a datetime object with the date of the maximum date
              for ending.
          daily: bool, optional
              If True and the file is CF-Compliant, write out daily flows.
          filter_mode: str, optional
              You can get the daily average "mean" or the maximum "max".
              Default is "mean".
  
  
          Example writing entire time series to file:
  
          .. code:: python
  
              from RAPIDpy import RAPIDDataset
  
              river_id = 3624735
              path_to_rapid_qout = '/path/to/Qout.nc'
  
              with RAPIDDataset(path_to_rapid_qout) as qout_nc:
                  #for writing entire time series to file
                  qout_nc.write_flows_to_csv('/timeseries/Qout_3624735.csv',
                                             river_id=river_id,
                                             )
  
  
                  #if file is CF compliant, you can write out daily average
  
                  #NOTE: Getting the river index is not necessary
                  #this is just an example of how to use this
                  river_index = qout_nc.get_river_index(river_id)
                  qout_nc.write_flows_to_csv('/timeseries/Qout_daily.csv',
                                             river_index=river_index,
                                             daily=True,
                                             )
  
          Example writing entire time series as daily average to file:
  
          .. code:: python
  
              from RAPIDpy import RAPIDDataset
  
              river_id = 3624735
              path_to_rapid_qout = '/path/to/Qout.nc'
  
              with RAPIDDataset(path_to_rapid_qout) as qout_nc:
                  #NOTE: Getting the river index is not necessary
                  #this is just an example of how to use this
                  river_index = qout_nc.get_river_index(river_id)
  
                  #if file is CF compliant, you can write out daily average
                  qout_nc.write_flows_to_csv('/timeseries/Qout_daily.csv',
                                             river_index=river_index,
                                             daily=True,
                                             )
  
          Example writing entire time series as daily average to file:
  
          .. code:: python
  
              from datetime import datetime
              from RAPIDpy import RAPIDDataset
  
              river_id = 3624735
              path_to_rapid_qout = '/path/to/Qout.nc'
  
              with RAPIDDataset(path_to_rapid_qout) as qout_nc:
                  # if file is CF compliant, you can filter by date
                  qout_nc.write_flows_to_csv(
                      '/timeseries/Qout_daily_date_filter.csv',
                      river_id=river_id,
                      daily=True,
                      date_search_start=datetime(2002, 8, 31),
                      date_search_end=datetime(2002, 9, 15),
                      filter_mode="max"
                  )
          """
          if river_id is not None:
              river_index = self.get_river_index(river_id)
          elif river_id is None and river_index is None:
              raise ValueError("Need reach id or reach index ...")
  
          # analyze and write
          if self.is_time_variable_valid() or self._is_legacy_time_valid():
              qout_df = self.get_qout_index(river_index,
                                            date_search_start=date_search_start,
                                            date_search_end=date_search_end,
                                            daily=daily,
                                            filter_mode=filter_mode,
                                            as_dataframe=True)
  
              qout_df.to_csv(path_to_output_file, header=False)
  
          else:
              log("Valid time variable not found. Printing values only ...",
                  "WARNING")
              qout_arr = self.get_qout_index(river_index)
              with open_csv(path_to_output_file, 'w') as outcsv:
                  writer = csv_writer(outcsv)
                  for index in xrange(len(qout_arr)):
                      writer.writerow([index, "{0:.5f}".format(qout_arr[index])])