Exemple #1
0
    def test_read_csv_file(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        file = os.path.join(
            os.path.abspath(
                os.path.split(__file__)[0]),
            "data",
            "ACA.PA.txt")

        f = TextFileColumns(file, fLOG=fLOG)
        f.open()
        rows = list(f)
        f.close()
        for l in rows[:5]:
            fLOG(l)
            assert isinstance(l, dict)
            assert isinstance(l["Adj_Close"], float)
Exemple #2
0
    def test_sort(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        data = os.path.join(os.path.abspath(
            os.path.split(__file__)[0]), "data")
        file1 = os.path.join(data, "tour2_2007_ext0.txt")
        file2 = os.path.join(data, "tour2_2007_ext1.txt")
        temp = get_temp_folder(__file__, "temp_sort")
        out = os.path.join(temp, "output.txt")

        # fusion
        fLOG("fusion")
        TextFileColumns.fusion("nomdudepartement", [file1, file2], output=out,
                               force_header=True, fLOG=fLOG)
        with open(out, "r", encoding="utf-8") as f:
            lines = f.readlines()
        found = 0
        for i, line in enumerate(lines):
            if "INCONNU" in line:
                found = i
        self.assertEqual(found, 37)

        # sort
        fLOG("sort")
        text_file = TextFileColumns(out, force_header=True)
        outs = os.path.join(temp, "output_sort.txt")
        text_file.sort(outs, "nomdudepartement", maxmemory=2 ** 10, fLOG=fLOG,
                       folder=temp)
        assert os.path.exists(outs)

        with open(outs, "r", encoding="utf-8") as f:
            lines = f.readlines()
        found = 0
        for i, line in enumerate(lines):
            if "INCONNU" in line:
                found = i
        self.assertEqual(found, 51)
Exemple #3
0
    def test_read_csv_file(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        file = os.path.join(os.path.abspath(os.path.split(__file__)[0]),
                            "data", "ACA.PA.txt")

        f = TextFileColumns(file, fLOG=fLOG)
        f.open()
        rows = list(f)
        f.close()
        for l in rows[:5]:
            fLOG(l)
            assert isinstance(l, dict)
            assert isinstance(l["Adj_Close"], float)
Exemple #4
0
    def test_sort(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        data = os.path.join(os.path.abspath(os.path.split(__file__)[0]),
                            "data")
        file1 = os.path.join(data, "tour2_2007_ext0.txt")
        file2 = os.path.join(data, "tour2_2007_ext1.txt")
        temp = get_temp_folder(__file__, "temp_sort")
        out = os.path.join(temp, "output.txt")

        # fusion
        fLOG("fusion")
        TextFileColumns.fusion("nomdudepartement", [file1, file2],
                               output=out,
                               force_header=True,
                               fLOG=fLOG)
        with open(out, "r", encoding="utf-8") as f:
            lines = f.readlines()
        found = 0
        for i, line in enumerate(lines):
            if "INCONNU" in line:
                found = i
        self.assertEqual(found, 37)

        # sort
        fLOG("sort")
        text_file = TextFileColumns(out, force_header=True)
        outs = os.path.join(temp, "output_sort.txt")
        text_file.sort(outs,
                       "nomdudepartement",
                       maxmemory=2**10,
                       fLOG=fLOG,
                       folder=temp)
        assert os.path.exists(outs)

        with open(outs, "r", encoding="utf-8") as f:
            lines = f.readlines()
        found = 0
        for i, line in enumerate(lines):
            if "INCONNU" in line:
                found = i
        self.assertEqual(found, 51)