Android Open Source - senhancelib E C G Csv Reader






From Project

Back to project page senhancelib.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project senhancelib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.uos.nbp.senhance;
// w ww. ja  v  a 2 s  .co  m
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Reads a csv file containing ecg data. Assumes at least two columns, where the first column contains
 * the time and the sceond ecgChII. Everything starting with # is ignored.
 * 
 * @author aswolinskiy
 *
 */
public class ECGCsvReader {
  
  private int[] times;
  private int[] ecgChII;
  
  private int maxEntryNr = Integer.MAX_VALUE;
  
  public void read(BufferedReader br){
    try {
      List<String> lines = new ArrayList<String>();
      
      String line = null;
      int lineNumber = 0;
 
      while( (line = br.readLine()) != null && lineNumber < maxEntryNr){
        if (line.startsWith("#")){
          continue;
        }
        lines.add(line);
        lineNumber++;
      }
      
      times = new int[lines.size()];
      ecgChII = new int[lines.size()];
      
      for (int i=0; i<lines.size();i++){
        line = lines.get(i);
        String[] parts = line.split(",");
        //TODO: asserts
        times[i] = Integer.parseInt(parts[0]);
        ecgChII[i] = Integer.parseInt(parts[1]);
      }
      
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }



  public int[] getTimes() {
    return times;
  }



  public int[] getEcgChII() {
    return ecgChII;
  }



  public void setMaxEntryNr(int maxEntryNr) {
    this.maxEntryNr = maxEntryNr;
  }

}




Java Source Code List

de.uos.nbp.BooleanProperties.java
de.uos.nbp.Utils.java
de.uos.nbp.senhance.DataLogger.java
de.uos.nbp.senhance.ECGCsvReader.java
de.uos.nbp.senhance.EventLoggingActivity.java
de.uos.nbp.senhance.EventSequenceAdapter.java
de.uos.nbp.senhance.EventTag.java
de.uos.nbp.senhance.LoggerApplication.java
de.uos.nbp.senhance.SDLogger.java
de.uos.nbp.senhance.bluetooth.BluetoothPacketConnection.java
de.uos.nbp.senhance.bluetooth.BluetoothService.java
de.uos.nbp.senhance.bluetooth.DeviceListActivity.java
de.uos.nbp.senhance.bluetooth.FramedPacketConnection.java
de.uos.nbp.senhance.bluetooth.PacketConnectionHandler.java
de.uos.nbp.senhance.bluetooth.PacketConnection.java
de.uos.nbp.senhance.datasource.ControlSource.java
de.uos.nbp.senhance.datasource.DataSink.java
de.uos.nbp.senhance.datasource.DataSourceBase.java
de.uos.nbp.senhance.datasource.DataSource.java
de.uos.nbp.senhance.datasource.DummySourceThread.java