Ejemplo n.º 1
0
 def test_negative2(self):
     with pytest.raises(Exception) as excinfo:
         convert_func.split_line("a\tb\tc", 2, 0)
     assert "The wrong column number in line 0. There shoud be 2 columns, 3 found" in str(
         excinfo)
Ejemplo n.º 2
0
 def test_positive1(self):
     assert convert_func.split_line("a\tb\tc", 3, 0) == ["a", "b", "c"]
Ejemplo n.º 3
0
 def test_positive3(self):
     assert convert_func.split_line("a\tb\t\tc\t", 5,
                                    0) == ["a", "b", "", "c", ""]
Ejemplo n.º 4
0
        line_counter = 1

        line_dict = process_columns(columns)
        #Preparing statusbar
        ten_percent_size = file_size / 10
        if file_size > 50000:
            mod_lines = math.floor(file_size / 5000)
        else:
            mod_lines = 10000

        #Processing lines
        for input_line in f_in:
            line_counter += 1
            processed_size += len(input_line)

            if line_counter % mod_lines == 0 and ten_percent_size > 5000:
                print("Approximately {0}% reached".format(
                    math.floor((processed_size / file_size) * 100)))

            cutted_line = cut_line(input_line, line_counter)

            input_list = split_line(cutted_line, len(line_dict), line_counter)

            for cc, ll in zip(line_dict.keys(), input_list):
                line_dict[cc] = ll

            result_string = line.process_line(line_dict, line_counter)

            f_out.write(result_string)
            f_out.write("\n")