Update in saving the csv. Sorting the data in aesc order and only taking the values between the specified range. Also adding the headers. [Working]
This commit is contained in:
@@ -16,6 +16,9 @@ object Constants {
|
||||
const val WAVELENGTH_OF_INTEREST_ONE = 427
|
||||
const val WAVELENGTH_OF_INTEREST_TWO = 555
|
||||
|
||||
const val MIN_WAVELENGTH_RANGE_TO_RECORD = 350
|
||||
const val MAX_WAVELENGTH_RANGE_TO_RECORD = 750
|
||||
|
||||
const val DEVICE_PRODUCT_ID = 24597
|
||||
const val DEVICE_VENDOR_ID = 1027
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.example.hpos.domain
|
||||
|
||||
import com.example.hpos.data.constant.Constants
|
||||
import com.example.hpos.data.model.TestRightCalculationData
|
||||
import com.opencsv.CSVWriter
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.util.Collections.sort
|
||||
|
||||
class SaveRawData {
|
||||
|
||||
@@ -11,12 +13,22 @@ class SaveRawData {
|
||||
|
||||
val fullPath = "$folderPath/$fileName"
|
||||
val writer = CSVWriter(FileWriter(fullPath))
|
||||
|
||||
sort(matrix) { one: ArrayList<Double>, two: ArrayList<Double> ->
|
||||
one[0].compareTo(two[0])
|
||||
}
|
||||
|
||||
val content = ArrayList<Array<String>>()
|
||||
content.add(arrayOf("NM", "CA"))
|
||||
|
||||
for (eachRow in matrix){
|
||||
|
||||
if (eachRow[0] >= Constants.MIN_WAVELENGTH_RANGE_TO_RECORD && eachRow[0] < Constants.MAX_WAVELENGTH_RANGE_TO_RECORD+1) {
|
||||
// val rowContent = arrayOf(String.format("%.3f", eachRow[0]), String.format("%.3f", eachRow[1]))
|
||||
val rowContent = arrayOf(String.format("%.10f", eachRow[0]), String.format("%.10f", eachRow[1]))
|
||||
content.add(rowContent)
|
||||
val rowContent =
|
||||
arrayOf(String.format("%.10f", eachRow[0]), String.format("%.10f", eachRow[1]))
|
||||
content.add(rowContent)
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeAll(content) // data is adding to csv
|
||||
|
||||
Reference in New Issue
Block a user