Esempio n. 1
0
def test_read_xlsx(table, tmpdir):
    filename = str(tmpdir.mkdir("data").join("table.xlsx"))
    table.to_excel(filename, index=False)
    df = read_tabular(filename)
    assert (df["integer"] == table["integer"]).all()
    assert isclose(df["numeric"], table["numeric"]).all()
    assert (df["comments"].isnull() == table["comments"].isnull()).all()
    assert (df.loc[df["comments"].notnull(), "comments"] ==
            table.loc[table["comments"].notnull(), "comments"]).all()
Esempio n. 2
0
def test_read_tsv(table, tmpdir):
    filename = str(tmpdir.mkdir("data").join("table.tsv"))
    table.to_csv(filename, sep="\t", index=False, encoding="utf-8")
    df = read_tabular(filename)
    assert (df["integer"] == table["integer"]).all()
    assert isclose(df["numeric"], table["numeric"]).all()
    assert (df["comments"].isnull() == table["comments"].isnull()).all()
    assert (df.loc[df["comments"].notnull(), "comments"] ==
            table.loc[table["comments"].notnull(), "comments"]).all()
Esempio n. 3
0
    def load(self, dtype_conversion=None):
        """
        Load the data table and corresponding validation schema.

        Parameters
        ----------
        dtype_conversion : dict
            Column names as keys and corresponding type for loading the data.
            Please take a look at the `pandas documentation
            <https://pandas.pydata.org/pandas-docs/stable/io.html#specifying-column-data-types>`__
            for detailed explanations.

        """
        self.data = read_tabular(self.filename, dtype_conversion)
        with open_text(memote.experimental.schemata,
                       self.SCHEMA,
                       encoding="utf-8") as file_handle:
            self.schema = json.load(file_handle)
Esempio n. 4
0
 def load(self):
     """Load the data table and corresponding validation schema."""
     self.data = read_tabular(self.filename)
     with open_text(memote.experimental.schemata, self.SCHEMA,
                    encoding="utf-8") as file_handle:
         self.schema = json.load(file_handle)