Exemplo n.º 1
0
    def test_dicts_to_csv(self):
        output_file = StringIO.StringIO()

        obj1 = {"a": "v1", "b": "v2"}
        obj2 = {"a": "v\"'3", "b": "v4"}
        obj3 = {"a": "v5", "c": "v6"}

        dicts_to_csv([obj1, obj2, obj3], output_file)
        result = output_file.getvalue().strip("\r\n")

        self.assertEquals('a,b,c\r\nv1,v2,\r\n"v""\'3",v4,\r\nv5,,v6', result)
Exemplo n.º 2
0
    def test_dicts_to_csv(self):
        output_file = StringIO.StringIO()

        obj1 = { 'a': 'v1', 'b': 'v2'}
        obj2 = { 'a': 'v"\'3', 'b': 'v4'}
        obj3 = { 'a': 'v5', 'c': 'v6'}

        dicts_to_csv([obj1, obj2, obj3], output_file)
        result = output_file.getvalue().strip('\r\n')

        self.assertEquals('a,b,c\r\nv1,v2,\r\n"v""\'3",v4,\r\nv5,,v6', result)
Exemplo n.º 3
0
def mergeResult(resultBase, outputFile):
    list_dir = os.walk(resultBase)
    output = open(outputFile, "w")
    result_list = []
    for root, dirs, files in list_dir:
        for f in files:
            if f.startswith("."):
                continue
            file_open = open(root + "/" + f, "rb")
            setting = pickle.load(file_open)
            eval_list = setting.evalMethods
            eval_num = len(eval_list)
            result_num = len(eval_list[0].value)
            for i in range(result_num):
                abstract = {}
                abstract.update(setting.abstract)
                for eval_index in range(eval_num):
                    abstract.update({eval_list[eval_index].name: eval_list[eval_index].value[i]})
                result_list.append(abstract)

    dicts_to_csv(result_list, output)