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)
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)
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)
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)
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
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)
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)
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')
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)