Beispiel #1
0
    def test_csv_encoding(self):
        reader_utf8 = CSVReaderPerThread(os.path.join(RESOURCES_DIR, "data/encoding_utf8.csv"), loop=False)
        reader_utf16 = CSVReaderPerThread(os.path.join(RESOURCES_DIR, "data/encoding_utf16.csv"), loop=False)
        data_utf8, data_utf16 = [], []

        reader_utf8.read_vars()
        data_utf8.append(reader_utf8.get_vars())

        reader_utf16.read_vars()
        data_utf16.append(reader_utf16.get_vars())

        self.assertEqual(data_utf8, data_utf16)
Beispiel #2
0
    def test_reader_without_loop(self):
        """ check different reading speed, fieldnames and separators """
        reader = CSVReaderPerThread(os.path.join(RESOURCES_DIR, "data/source0.csv"), loop=False)
        data = []
        try:
            for i in range(20):
                reader.read_vars()
                data.append(reader.get_vars())
        except NormalShutdown:
            self.assertEqual(6, len(data))
            return

        self.fail()
Beispiel #3
0
    def test_csv_encoding(self):
        reader_utf8 = CSVReaderPerThread(os.path.join(os.path.dirname(__file__), "resources/data/encoding_utf8.csv"),
                                         loop=False)
        reader_utf16 = CSVReaderPerThread(os.path.join(os.path.dirname(__file__), "resources/data/encoding_utf16.csv"),
                                          loop=False)
        data_utf8, data_utf16 = [], []

        reader_utf8.read_vars()
        data_utf8.append(reader_utf8.get_vars())

        reader_utf16.read_vars()
        data_utf16.append(reader_utf16.get_vars())

        self.assertEqual(data_utf8, data_utf16)