本文整理汇总了Python中pyexcel.save_as函数的典型用法代码示例。如果您正苦于以下问题:Python save_as函数的具体用法?Python save_as怎么用?Python save_as使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了save_as函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_to_database
def save_to_database(
self,
session=None, table=None, initializer=None, mapdict=None,
auto_commit=True,
**keywords):
"""
Save data from a sheet to database
:param session: a SQLAlchemy session
:param table: a database table
:param initializer: a custom table initialization function if you have one
:param mapdict: the explicit table column names if your excel data do not have the exact column names
:param keywords: additional keywords to :meth:`pyexcel.Sheet.save_to_database`
"""
params = self.get_params(**keywords)
if 'name_columns_by_row' not in params:
params['name_columns_by_row'] = 0
if 'name_rows_by_column' not in params:
params['name_rows_by_column'] = -1
params['dest_session']=session
params['dest_table'] = table
params['dest_initializer']=initializer
params['dest_mapdict'] = mapdict
params['dest_auto_commit']=auto_commit
pe.save_as(**params)
示例2: create_sample_file1
def create_sample_file1(file):
data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1]
table = []
table.append(data[:4])
table.append(data[4:8])
table.append(data[8:12])
pyexcel.save_as(array=table, dest_file_name=file)
示例3: create_sample_file1
def create_sample_file1(file):
data = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 1.1, 1]
table = []
table.append(data[:4])
table.append(data[4:8])
table.append(data[8:12])
pyexcel.save_as(dest_file_name=file, array=table)
示例4: setUp
def setUp(self):
"""
Make a test csv file as:
1, 2, 3, 4
5, 6, 7, 8
9, 10, 11, 12
"""
self.testfile1 = "testcsv1.csv"
content = [
[1, 'a'],
[2, 'b'],
[3, 'c'],
[4, 'd'],
[5, 'e'],
[6, 'f'],
[7, 'g'],
[8, 'h']
]
pe.save_as(dest_file_name=self.testfile1,
array=content)
self.testfile2 = "testcsv2.csv"
content = [
[1, 'a', 'c'],
[2, 'b', 'h'],
[3, 'c', 'c'],
[8, 'h', 'd']
]
pe.save_as(dest_file_name=self.testfile2,
array=content)
示例5: test_writing_multiline_ods
def test_writing_multiline_ods():
content = "2\n3\n4\n993939\na"
testfile = "writemultiline.ods"
array = [[content, "test"]]
pyexcel.save_as(array=array, dest_file_name=testfile)
sheet = pyexcel.get_sheet(file_name=testfile)
assert sheet[0, 0] == content
os.unlink(testfile)
示例6: setUp
def setUp(self):
self.data = {
"1": [1, 2, 3, 4, 5, 6, 7, 8],
"3": [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8],
"5": [2, 3, 4, 5, 6, 7, 8, 9],
}
self.testfile = "test.xls"
pe.save_as(dest_file_name=self.testfile, adict=self.data)
示例7: setUp
def setUp(self):
self.excel_filename = "testdateformat.csv"
self.data = [[
datetime.date(2014,12,25),
datetime.datetime(2014,12,25,11,11,11),
datetime.datetime(2014,12,25,11,11,11,10)
]]
pe.save_as(dest_file_name=self.excel_filename, array=self.data)
示例8: test_new_normal_usage_irregular_columns
def test_new_normal_usage_irregular_columns(self):
content = [
[1, 2, 3],
[4, 588, 6],
[7, 8]
]
pe.save_as(array=content, dest_file_name=self.testfile)
self._check_test_file('new_normal_usage_irregular_columns')
示例9: test_no_title_single_sheet
def test_no_title_single_sheet(self):
content = [
[1, 2, 3],
[4, 588, 6],
[7, 8, 999]
]
pe.save_as(array=content, dest_file_name=self.testfile, dest_write_title=False)
self._check_test_file('no_title_single_sheet')
示例10: test_new_normal_usage
def test_new_normal_usage(self):
content = [
[1, 2, 3],
[4, 588, 6],
[7, 8, 999]
]
pe.save_as(array=content, dest_file_name=self.testfile)
self._check_test_file('new_normal_usage')
示例11: 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
示例12: 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
示例13: test_save_as_and_append_colnames
def test_save_as_and_append_colnames(self):
data = [[1, 2, 3], [4, 5, 6]]
sheet = pe.Sheet(data)
testfile = "testfile.xls"
testfile2 = "testfile.xls"
sheet.save_as(testfile)
pe.save_as(file_name=testfile, out_file=testfile2, colnames=["X", "Y", "Z"])
array = pe.get_array(file_name=testfile2)
assert array == [["X", "Y", "Z"], [1, 2, 3], [4, 5, 6]]
示例14: CVSOutput
def CVSOutput(self,sortedTempSimilarityTuple):
data = []
for item in sortedTempSimilarityTuple:
dataTuple = []
relations = item[0].split("-")
dataTuple.append(relations[0])
dataTuple.append(relations[1])
dataTuple.append(item[1])
data.append(dataTuple)
pyexcel.save_as(array = data, dest_file_name = 'testCSV.csv')
示例15: test_new_normal_usage
def test_new_normal_usage(self):
content = [
[1, 2, 3],
[4, 588, 6],
[7, 8, 999]
]
pe.save_as(array=content, dest_file_name=self.testfile)
with open(self.testfile, "r") as f:
written_content = json.load(f)
assert written_content == content