code: def resample_impl(barFeed, frequency, csvFile):
      instruments = barFeed.getRegisteredInstruments()
      if len(instruments) != 1:
          raise Exception(
              "Only barfeeds with 1 instrument can be resampled"
          )
  
      csvWriter = CSVFileWriter(csvFile)
  
      def on_bar(ds, dateTime, value):
          csvWriter.writeBar(value)
  
      insrumentDS = barFeed[instruments[0]]
      resampledDS = resampled.ResampledBarDataSeries(
          insrumentDS, frequency
      )
      resampledDS.getNewValueEvent().subscribe(on_bar)
  
      # Process all bars.
      disp = dispatcher.Dispatcher()
      disp.addSubject(barFeed)
      disp.run()
      resampledDS.pushLast()
  
      csvWriter.close()
  
file_path: pyalgotrade/pyalgotrade/tools/resample.py
imports: import os
  from pyalgotrade import dispatcher
  from pyalgotrade.dataseries import resampled
label_desc: Use image node_id 1 for calling a global function with example usage: resample_impl(barFeed, frequency, csvFile) without return types