本文整理汇总了Python中pyexcel.get_dict函数的典型用法代码示例。如果您正苦于以下问题:Python get_dict函数的具体用法?Python get_dict怎么用?Python get_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dict函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_save_book_as_to_database
def test_save_book_as_to_database(self):
data = [
["X", "Y", "Z"],
[1, 2, 3],
[4, 5, 6]
]
data1 = [
["A", "B", "C"],
[1, 2, 3],
[4, 5, 6]
]
sheet_dict = {
Signature.__tablename__: data,
Signature2.__tablename__: data1
}
pe.save_book_as(bookdict=sheet_dict,
dest_session=self.session,
dest_tables=[Signature, Signature2])
result = pe.get_dict(session=self.session, table=Signature)
assert result == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
result = pe.get_dict(session=self.session, table=Signature2)
assert result == {
"A": [1, 4],
"B": [2, 5],
"C": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:30,代码来源:test_signature_fuction.py
示例2: test_book_save_a_dict2
def test_book_save_a_dict2(self):
data = [
[1, 4, 'X'],
[2, 5, 'Y'],
[3, 6, 'Z']
]
data1 = [
[1, 4, 'A'],
[2, 5, 'B'],
[3, 6, 'C']
]
sheet_dict = {
"sheet": data,
"sheet1": data1
}
book = pe.Book(sheet_dict)
book['sheet'].transpose()
book['sheet'].name_columns_by_row(2)
book['sheet1'].transpose()
book['sheet1'].name_columns_by_row(2)
book.save_to_database(
self.session,
[Signature,Signature2])
result = pe.get_dict(session=self.session, table=Signature)
assert result == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
result = pe.get_dict(session=self.session, table=Signature2)
assert result == {
"A": [1, 4],
"B": [2, 5],
"C": [3, 6]
}
开发者ID:CHEN-JIANGHANG,项目名称:pyexcel,代码行数:35,代码来源:test_signature_fuction.py
示例3: test_get_dict_from_sql
def test_get_dict_from_sql(self):
adict = pe.get_dict(session=Session(), table=Signature)
assert adict == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:7,代码来源:test_signature_fuction.py
示例4: test_get_dict_from_dict
def test_get_dict_from_dict(self):
data = {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
result = pe.get_dict(adict=data)
assert result == data
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:8,代码来源:test_signature_fuction.py
示例5: test_get_dict_from_file
def test_get_dict_from_file(self):
data = [["X", "Y", "Z"], [1, 2, 3], [4, 5, 6]]
sheet = pe.Sheet(data)
testfile = "testfile.xls"
sheet.save_as(testfile)
result = pe.get_dict(file_name=testfile)
assert result == {"X": [1, 4], "Y": [2, 5], "Z": [3, 6]}
os.unlink(testfile)
开发者ID:bdeeney,项目名称:pyexcel,代码行数:8,代码来源:test_signature_fuction.py
示例6: test_save_an_array
def test_save_an_array(self):
data = [[1, 4, "X"], [2, 5, "Y"], [3, 6, "Z"]]
sheet = pe.Sheet(data)
sheet.transpose()
sheet.name_columns_by_row(2)
sheet.save_to_database(self.session, Signature)
result = pe.get_dict(session=self.session, table=Signature)
assert result == {"X": [1, 4], "Y": [2, 5], "Z": [3, 6]}
开发者ID:bdeeney,项目名称:pyexcel,代码行数:8,代码来源:test_signature_fuction.py
示例7: test_save_an_array4
def test_save_an_array4(self):
data = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
sheet = pe.Sheet(data)
sheet.name_columns_by_row(0)
mapdict = {"A": "X", "B": "Y", "C": "Z"}
sheet.save_to_database(self.session, Signature, mapdict=mapdict)
result = pe.get_dict(session=self.session, table=Signature)
assert result == {"X": [1, 4], "Y": [2, 5], "Z": [3, 6]}
开发者ID:bdeeney,项目名称:pyexcel,代码行数:8,代码来源:test_signature_fuction.py
示例8: test_issue_10
def test_issue_10(self):
thedict = OrderedDict()
thedict.update({"Column 1": [1,2,3]})
thedict.update({"Column 2": [1,2,3]})
thedict.update({"Column 3": [1,2,3]})
pe.save_as(adict=thedict, dest_file_name="issue10.xls")
newdict = pe.get_dict(file_name="issue10.xls")
assert isinstance(newdict, OrderedDict) == True
assert thedict == newdict
开发者ID:CHEN-JIANGHANG,项目名称:pyexcel,代码行数:9,代码来源:test_bug_fixes.py
示例9: test_save_as_to_database
def test_save_as_to_database(self):
adict = {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
pe.save_as(adict=adict, dest_session=self.session, dest_table=Signature)
result = pe.get_dict(session=self.session, table=Signature)
assert adict == result
开发者ID:pombredanne,项目名称:pyexcel,代码行数:9,代码来源:test_signature_fuction.py
示例10: test_book_save_a_dict
def test_book_save_a_dict(self):
data = [[1, 4, "X"], [2, 5, "Y"], [3, 6, "Z"]]
sheet_dict = {"sheet": data}
book = pe.Book(sheet_dict)
book["sheet"].transpose()
book["sheet"].name_columns_by_row(2)
book.save_to_database(self.session, [Signature])
result = pe.get_dict(session=self.session, table=Signature)
assert result == {"X": [1, 4], "Y": [2, 5], "Z": [3, 6]}
开发者ID:bdeeney,项目名称:pyexcel,代码行数:9,代码来源:test_signature_fuction.py
示例11: test_save_a_dict3
def test_save_a_dict3(self):
adict = {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
sheet = pe.get_sheet(adict=adict, name_columns_by_row=0)
sheet.save_to_database(self.session, Signature)
result = pe.get_dict(session=self.session, table=(Signature))
assert adict == result
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:10,代码来源:test_signature_fuction.py
示例12: test_save_a_dict2
def test_save_a_dict2(self):
adict = {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
sheet = pe.get_sheet(adict=adict)
sheet.save_to_database(self.session, Signature)
result = pe.get_dict(session=self.session, table=Signature)
assert adict == result
开发者ID:pombredanne,项目名称:pyexcel,代码行数:10,代码来源:test_signature_fuction.py
示例13: test_save_an_array7
def test_save_an_array7(self):
data = [["X", "Y", "Z"], [1, 2, 3], [4, 5, 6]]
sheet = pe.Sheet(data)
sheet.name_columns_by_row(0)
def make_signature(row):
return Signature(X=row["X"], Y=row["Y"], Z=row["Z"])
sheet.save_to_database(self.session, Signature, initializer=make_signature)
result = pe.get_dict(session=self.session, table=Signature)
assert result == {"X": [1, 4], "Y": [2, 5], "Z": [3, 6]}
开发者ID:bdeeney,项目名称:pyexcel,代码行数:11,代码来源:test_signature_fuction.py
示例14: test_get_dict_from_array
def test_get_dict_from_array(self):
data = [
["X", "Y", "Z"],
[1, 2, 3],
[4, 5, 6]
]
result = pe.get_dict(array=data)
assert result == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:12,代码来源:test_signature_fuction.py
示例15: test_get_dict_from_records
def test_get_dict_from_records(self):
data = [
{"X": 1, "Y": 2, "Z": 3},
{"X": 4, "Y": 5, "Z": 6}
]
expected = {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
result = pe.get_dict(records=data)
assert result == expected
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:12,代码来源:test_signature_fuction.py
示例16: test_get_dict_from_memory
def test_get_dict_from_memory(self):
data = [
["X", "Y", "Z"],
[1, 2, 3],
[4, 5, 6]
]
content = pe.save_as(dest_file_type="xls", array=data)
adict = pe.get_dict(file_content=content.getvalue(), file_type="xls")
assert adict == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:13,代码来源:test_signature_fuction.py
示例17: get_dict
def get_dict(self, **keywords):
"""Get a dictionary from the file
:param sheet_name: For an excel book, there could be multiple
sheets. If it is left unspecified, the
sheet at index 0 is loaded. For 'csv',
'tsv' file, *sheet_name* should be None anyway.
:param keywords: additional key words
:returns: A dictionary
"""
params = self.get_params(**keywords)
if 'name_columns_by_row' not in params:
params['name_columns_by_row'] = 0
return pe.get_dict(**params)
开发者ID:CometHale,项目名称:AMS30,代码行数:14,代码来源:__init__.py
示例18: test_book_save_a_dict
def test_book_save_a_dict(self):
data = [
[1, 4, 'X'],
[2, 5, 'Y'],
[3, 6, 'Z']
]
sheet1 = Signature.__tablename__
sheet_dict = {
sheet1: data
}
book = pe.Book(sheet_dict)
book[sheet1].transpose()
book[sheet1].name_columns_by_row(2)
book.save_to_database(self.session, [Signature])
result = pe.get_dict(session=self.session, table=Signature)
assert result == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:20,代码来源:test_signature_fuction.py
示例19: test_save_an_array3
def test_save_an_array3(self):
data = [
[1, 4, 'A'],
[2, 5, 'B'],
[3, 6, 'C']
]
sheet = pe.Sheet(data)
sheet.transpose()
sheet.name_columns_by_row(2)
mapdict = [
'X',
'Y',
'Z'
]
sheet.save_to_database(self.session, Signature, mapdict=mapdict)
result = pe.get_dict(session=self.session, table=Signature)
assert result == {
"X": [1, 4],
"Y": [2, 5],
"Z": [3, 6]
}
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:21,代码来源:test_signature_fuction.py
示例20: test_get_dict
def test_get_dict(self):
pe.get_dict(x="something")
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:2,代码来源:test_signature_fuction.py
注:本文中的pyexcel.get_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论