Store data in a .csv file with a certain binning

Hi,

I would like to store energies deposited in a detector based on a certain binning (2 keV bin size) to a .csv-file.
I’m fine retrieving the data out from a .root file.

Is there any way to do this?