All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.csiro.variantspark.output.CSVFeatureSink.scala Maven / Gradle / Ivy

The newest version!
package au.csiro.variantspark.output

import au.csiro.variantspark.input.FeatureSource
import java.io.FileWriter
import au.csiro.pbdava.ssparkle.common.utils.CSVUtils
import java.io.File

/**
  * This only works for smallish datasets (used local files)
  */
case class CSVFeatureSink(fileName: String) extends FeatureSink {

  def save(fs: FeatureSource) {
    CSVUtils.withFile(new File(fileName)) { csvWriter =>
      csvWriter.writeRow("" :: fs.sampleNames)
      csvWriter.writeAll(fs.features.collect().toSeq.map(f => f.label :: f.valueAsStrings))
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy