def test_io(doc = DOC_1):    
    p = docstring_to_file(doc, "test_yaml_doc.txt")
    assert doc == "\n".join([x[0] for x in yield_csv_rows(p)])
    y = get_yaml(p)
    assert y[0][0] == 'Something looking like a yaml'
    assert y[1]["key1"] == 'with two documents'
    delete_file(p)
Exemplo n.º 2
0
 def test_raw_data_import_from_csv_file(self):
     csvpath = self.csvfile()
     raw_rows = list(yield_csv_rows(csv_filename=csvpath))
     for i_raw_rows, j_investment_doc in zip(
             raw_rows, self.doc_as_iterable(self.INVESTMENT_DOC)):
         self.assertEqual(i_raw_rows, j_investment_doc)
     os.remove(csvpath)
Exemplo n.º 3
0
def test_io(doc=DOC_1):
    p = docstring_to_file(doc, "test_yaml_doc.txt")
    assert doc == "\n".join([x[0] for x in yield_csv_rows(p)])
    y = get_yaml(p)
    assert y[0][0] == 'Something looking like a yaml'
    assert y[1]["key1"] == 'with two documents'
    delete_file(p)
Exemplo n.º 4
0
def test_raw_data_import_from_csv_file():
    csvpath = csvfile()
    raw_rows = list(yield_csv_rows(csv_filename=csvpath))
    for i_raw_rows, j_investment_doc in zip(raw_rows,
                                            doc_as_iterable(INVESTMENT_DOC)):
        assert i_raw_rows == j_investment_doc
    os.remove(csvpath)
Exemplo n.º 5
0
def test_raw_data_import_from_csv_file():
    csvpath = csvfile()
    raw_rows = list(yield_csv_rows(csv_filename=csvpath))
    for i_raw_rows, j_investment_doc in zip(raw_rows, doc_as_iterable(INVESTMENT_DOC)):
        assert i_raw_rows == j_investment_doc
    os.remove(csvpath)
Exemplo n.º 6
0
def emit_raw_non_data_rows(raw_data_file):
    for row in yield_csv_rows(raw_data_file):
        if not is_year(row[0]):
            yield row
Exemplo n.º 7
0
def get_labelled_rows_by_segment(raw_data_file, yaml_spec_file, yaml_cfg_file):
    raw_rows = list(yield_csv_rows(raw_data_file))
    default_dicts = load_spec(yaml_spec_file)
    segment_specs = load_cfg(yaml_cfg_file)
    return label_raw_rows_by_segment(raw_rows, default_dicts, segment_specs)
Exemplo n.º 8
0
def get_labelled_rows_no_segments(raw_data_file, yaml_spec_file):
    raw_rows = yield_csv_rows(raw_data_file)
    spec_dicts = load_spec(yaml_spec_file)
    return raw_to_labelled_rows(raw_rows, spec_dicts)
Exemplo n.º 9
0
 def test_io(self):
     p = docstring_to_file(self.DOC_1, "test_yaml_doc.txt")
     self.assertEqual(self.DOC_1, "\n".join([x[0] for x in yield_csv_rows(p)]))
     y = get_yaml(p)
     self.assertEqual(y[0][0], 'Something looking like a yaml')
     self.assertEqual(y[1]["key1"], 'with two documents')
Exemplo n.º 10
0
def emit_raw_non_data_rows(raw_data_file):
    for row in yield_csv_rows(raw_data_file):
        if not is_year(row[0]):
            yield row
Exemplo n.º 11
0
def get_labelled_rows_by_segment(raw_data_file, yaml_spec_file, yaml_cfg_file):
    raw_rows = list(yield_csv_rows(raw_data_file))     
    default_dicts = load_spec(yaml_spec_file)
    segment_specs = load_cfg(yaml_cfg_file)
    return label_raw_rows_by_segment(raw_rows, default_dicts, segment_specs)
Exemplo n.º 12
0
def get_labelled_rows_no_segments(raw_data_file, yaml_spec_file):
    raw_rows = yield_csv_rows(raw_data_file)
    spec_dicts = load_spec(yaml_spec_file)
    return raw_to_labelled_rows(raw_rows, spec_dicts)
Exemplo n.º 13
0
 def test_raw_data_import_from_csv_file(self):
     csvpath = self.csvfile()
     raw_rows = list(yield_csv_rows(csv_filename=csvpath))
     for i_raw_rows, j_investment_doc in zip(raw_rows, self.doc_as_iterable(self.INVESTMENT_DOC)):
         self.assertEqual(i_raw_rows, j_investment_doc)
     os.remove(csvpath)