Exemple #1
0
class TestCSVExporter(unittest.TestCase):
    def setUp(self):
        self.tmp = TempDirectory()
        self.dir = self.tmp.makedir('foobar')
        self.exp = CSVExporter()
    def tearDown(self):
        TempDirectory.cleanup_all()
    def test_creation_of_export_file(self):
        filename = 'foobar.csv'
        values = [lib.Sensorsegment._make([0] * 6)]
        status = self.exp.export(values, self.dir+filename)
        self.assertTrue(os.path.isfile(self.dir+filename))
        self.assertTrue(status)
    def test_content_of_export_file(self):
        filename = 'foobar.csv'
        values = [lib.Sensorsegment._make([0] * 6),
                lib.Sensorsegment._make([1] * 6)
                ]
        self.exp.export(values, self.dir+filename, False, False)
        res = self.tmp.read(self.dir+filename)
        ref = b'0,0,0,0,0,0\r\n1,1,1,1,1,1\r\n'
        self.assertEqual(ref, res)
    def test_content_with_header_with_indices(self):
        filename = 'foobar.csv'
        values = [lib.Sensorsegment._make([0] * 6)]
        self.exp.export(values, self.dir+filename, True, True)
        res = self.tmp.read(self.dir+filename)
        ref = b'Index,accelX,accelY,accelZ,gyroX,gyroY,gyroZ\r\n1,0,0,0,0,0,0\r\n'
        self.assertEqual(ref, res)
    def test_content_with_header_without_indices(self):
        filename = 'foobar.csv'
        values = [lib.Sensorsegment._make([0] * 6)]
        self.exp.export(values, self.dir+filename, True, False)
        res = self.tmp.read(self.dir+filename)
        ref = b'accelX,accelY,accelZ,gyroX,gyroY,gyroZ\r\n0,0,0,0,0,0\r\n'
        self.assertEqual(ref, res)
    def test_content_without_header_with_indices(self):
        filename = 'foobar.csv'
        values = [lib.Sensorsegment._make([0] * 6)]
        self.exp.export(values, self.dir+filename, False, True)
        res = self.tmp.read(self.dir+filename)
        ref = b'1,0,0,0,0,0,0\r\n'
        self.assertEqual(ref, res)
Exemple #2
0
        # skip all non .dat files
        # TODO: this is ugly.
        # cleanup
        if '.dat' != os.path.splitext(pair[0].filename)[1]: continue
        raw = RawConverter([pair], [sensLeft, sensRight])
        raw.processDatFiles()
        leftRawValidationSegments = raw.initSensors[Orientation.left.name]\
                .normalizedSensorSegments
        rightRawValidationSegments = raw.initSensors[Orientation.right.name]\
                .normalizedSensorSegments
        currentSession = raw.sessionIdentifier
        currentExercise = raw.exerciseIdentifier


        # Raw Data Export
        rawValidation = CSVExporter()
        location = rawValidation.prepareOutputDir(
                        outputDir
                        , currentSession
                        , currentExercise)
        rawValidation.export(
                leftRawValidationSegments
                , location + 'leftSensorNormalized.csv'
                , cli.args.csv_headers)
        rawValidation.export(
                rightRawValidationSegments
                , location + 'rightSensorNormalized.csv'
                , cli.args.csv_headers)

    # Text Data Conversion
    txt = TxtConverter(importer.pairedFiles)
Exemple #3
0
 def setUp(self):
     self.tmp = TempDirectory()
     self.dir = self.tmp.makedir('foobar')
     self.exp = CSVExporter()