modified to write to csv in case hdf5 libs do not exist