예제 #1
0
 def _make_importer(self, path):
     fext = self._identify_filetype(path)
     if fext in ['txt', 'csv']:
         return ImporterTextFile(file_path=path)
     elif fext in ['xls', 'xlsx', 'xlsm']:
         return ImporterXlsFile(file_path=path)
     else:
         return ImporterTextFile(file_path=path)
예제 #2
0
 def test_simple_tab_sep(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'TabSep.txt'),
         have_var_names=False,
         have_obj_names=False,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
예제 #3
0
 def test_missing_values(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'HaveHoles.txt'),
         have_var_names=False,
         have_obj_names=False,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
     assert ds.missing_data
예제 #4
0
 def test_latin1_text(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'Names_iso-8859-1.txt'),
         char_encoding='latin_1',
         have_var_names=True,
         have_obj_names=True,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
예제 #5
0
 def test_utf8_text(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'Names_UTF-8.txt'),
         char_encoding='utf_8',
         have_var_names=True,
         have_obj_names=True,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
예제 #6
0
 def test_csv_empty_corner(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'CommaSeparated.csv'),
         delimiter=',',
         have_var_names=True,
         have_obj_names=True,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
예제 #7
0
 def test_obj_var_names(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'ObjVarNames.txt'),
         have_var_names=True,
         have_obj_names=True,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
     assert ds.obj_n[0] == 'Ost1'
     assert ds.var_n[0] == 'Var1'
예제 #8
0
 def test_comma_decimal_mark(self, tdd, ref):
     ifp = ImporterTextFile(
         file_path=join(tdd, 'Variants', 'CommaDecimalMark.txt'),
         delimiter='\t',
         decimal_mark='comma',
         have_var_names=False,
         have_obj_names=False,
     )
     ds = ifp.import_data()
     assert ds.n_objs == 12
     assert ds.n_vars == 5
     assert ds.mat.dtypes[0] == np.float64
예제 #9
0
                        height=400,
                        buttons=[OKButton])
        else:
            view = View(Item('valuescat',
                             editor=TabularEditor(adapter=aa),
                             show_label=False),
                        Item('handler.cp_clip', show_label=False),
                        title=header_txt,
                        resizable=True,
                        width=900,
                        height=400,
                        buttons=[OKButton])

        return view


if __name__ == '__main__':
    # from tests.conftest import simple_ds
    import os
    from importer_text_file import ImporterTextFile
    dpath = os.getenv('CC_TESTDATA', '.')
    dfile = os.path.join(dpath, 'Apples_DescrAnalysis_row&col_Cat.txt')
    itf = ImporterTextFile(file_path=dfile,
                           delimiter='\t',
                           have_obj_names=True)
    ds = itf.import_data()
    # import pudb; pu.db
    # ds = simple_ds()
    dstv = DSTableViewer(ds)
    dstv.configure_traits(view=dstv.get_view())