• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyexcel.get_sheet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyexcel.get_sheet函数的典型用法代码示例。如果您正苦于以下问题:Python get_sheet函数的具体用法?Python get_sheet怎么用?Python get_sheet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_sheet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: has_sheet

    def has_sheet(self):
        if self.sheetname == '':
            return True

        try:
            pyexcel.get_sheet(file_name=self.filename, sheet_name=self.sheetname)
            return True
        except:
            return False
开发者ID:aodn,项目名称:data-services,代码行数:9,代码来源:srs_oc_bodbaw_netcdf_creation.py


示例2: convert

def convert():

    #Definir formato de localização dos dados
    locale.setlocale(locale.LC_ALL, 'en_US')

    #Planilha - GND
    # Importa dados da planilha de Grandes Grupos de Despesa
    raw_sheet_gnd = pyexcel.get_sheet(file_name="/home/romulofloresta/server_app/xls2py/gnd-raw.xls")

    #Remove linhas e colunas desnecessárias
    raw_sheet_gnd.delete_rows(list(range(4))) #deleta linhas acima
    for i in range(3):
        raw_sheet_gnd.delete_rows([-1]) #deleta linhas abaixo
    raw_sheet_gnd.delete_columns([0, 2, 4, 5, 7])

    #Converte para tipo de dados python
    raw_sheet_gnd.name_columns_by_row(0)
    py_records_gnd = raw_sheet_gnd.to_records()

    #formata os valores de moeda
    for record in py_records_gnd:
        record['Autorizado'] = locale.currency(record["Autorizado"], symbol=None)
        record['Pago'] = locale.currency(record["Pago"], symbol=None)

    # Funções
    # Importa dados da planilha de Funções
    raw_sheet_func = pyexcel.get_sheet(file_name="/home/romulofloresta/server_app/xls2py/funcoes-raw.xls")

    #Remove linhas e colunas desnecessárias
    raw_sheet_func.delete_rows(list(range(4))) #deleta linhas acima
    for i in range(4):
        raw_sheet_func.delete_rows([-1]) #deleta linhas abaixo
    raw_sheet_func.delete_columns([1, 3, 4, 6])

    #Alterar título da coluna
    raw_sheet_func[0,0] = 'Funcao'

    #Converte para tipo de dados python
    raw_sheet_func.name_columns_by_row(0)
    py_records_func = raw_sheet_func.to_records()

    # Formata os campos
    for record in py_records_func:
        record['Funcao'] = record['Funcao'][4:]
        record['Autorizado'] = locale.currency(record["Autorizado"], symbol=None)
        record['Pago'] = locale.currency(record["Pago"], symbol=None)

    #Pega a versão do banco de dados
    with open('server_app/version.json') as f:
        data_version = json.load(f)
        f.close()

    # Retorna json com os dados
    response = json.dumps({'Funcao': py_records_func, 'GND': py_records_gnd, 'version': data_version['version'], 'updated':data_version['date']})
    return response
开发者ID:romulo5,项目名称:server_app,代码行数:55,代码来源:__init__.py


示例3: test_get_sheet_from_sql

 def test_get_sheet_from_sql(self):
     sheet = pe.get_sheet(session=Session(), table=Signature)
     assert sheet.to_array() == [
         ["X", "Y", "Z"],
         [1, 2, 3],
         [4, 5, 6]
     ]
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:7,代码来源:test_signature_fuction.py


示例4: test_upload_and_download

 def test_upload_and_download(self):
     for upload_file_type in FILE_TYPE_MIME_TABLE.keys():
         file_name = 'test.%s' % upload_file_type
         for download_file_type in FILE_TYPE_MIME_TABLE.keys():
             print("Uploading %s Downloading %s" % (upload_file_type,
                                                    download_file_type))
             sheet = pe.Sheet(self.data)
             io = sheet.save_to_memory(upload_file_type).getvalue()
             if not PY2:
                 if isinstance(io, bytes):
                     content = io
                 else:
                     content = io.encode('utf-8')
             else:
                 content = io
             response = self.app.post(
                 '/switch/%s' % download_file_type,
                 upload_files=[('file', file_name, content)],
             )
             eq_(response.content_type,
                 FILE_TYPE_MIME_TABLE[download_file_type])
             sheet = pe.get_sheet(file_type=download_file_type,
                                  file_content=response.body)
             sheet.format(int)
             array = sheet.to_array()
             assert array == self.data
开发者ID:pyexcel,项目名称:pyramid-excel,代码行数:26,代码来源:test_upload_n_download_excel.py


示例5: parse_bounds

def parse_bounds(file_path):
    if not (os.path.isfile(file_path)):
        print (file_path + " File not found!!!")
        return {"bounds" : []}
    sheet = pyexcel.get_sheet(file_name=file_path)
    bound_dict = {
        "record"  : sheet.column[1][0],
        "channel" : sheet.column[1][1],
        "neuron"  : sheet.column[1][2],
        "bounds"  : [],    
    }
    for idx in range(len(sheet.column[0][3:])):
        idx += 3
        
        tmp_bounds = sheet.column[1][idx].split(" ")
        if (len(tmp_bounds) == 1 and tmp_bounds[0] == ""):
            continue

        if (len(tmp_bounds) != 2):
            tmp_bounds = []
            tmp_bounds.append( sheet.column[1][idx] )
            tmp_bounds.append( sheet.column[2][idx] )
            
        #tmp_bounds[0] = min(tmp_bounds)
        #tmp_bounds[1] = max(tmp_bounds)
            
        tmp_dict = {
            'name' : sheet.column[0][idx],
            'lower_bound' : float(tmp_bounds[0]),
            'upper_bound' : float(tmp_bounds[1]),        
        }
        
        bound_dict["bounds"].append(tmp_dict)
    return (bound_dict)
开发者ID:ivanmysin,项目名称:spike_train_analisis,代码行数:34,代码来源:spike_train_from_final.py


示例6: test_issue_30

def test_issue_30():
    test_file = "issue_30.ods"
    sheet = pe.Sheet()
    sheet[0, 0] = 999999999999999
    sheet.save_as(test_file)
    sheet2 = pe.get_sheet(file_name=test_file)
    eq_(sheet[0, 0], sheet2[0, 0])
    os.unlink(test_file)
开发者ID:pyexcel,项目名称:pyexcel-ods,代码行数:8,代码来源:test_bug_fixes.py


示例7: main

def main(base_dir):
    # "example.csv","example.xlsx","example.ods", "example.xlsm"
    spreadsheet = pyexcel.get_sheet(file_name=os.path.join(base_dir,
                                                           "example.xls"))

    # rows() returns row based iterator, meaning it can be iterated row by row
    for row in spreadsheet.rows():
        print(row)
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:8,代码来源:read_row_by_row.py


示例8: test_auto_detect_int_false

 def test_auto_detect_int_false(self):
     sheet = pe.get_sheet(file_name=self.test_file, auto_detect_int=False)
     expected = dedent("""
     test_auto_detect_init.csv:
     +-----+-----+-----+
     | 1.0 | 2.0 | 3.1 |
     +-----+-----+-----+""").strip()
     self.assertEqual(str(sheet), expected)
开发者ID:schulzsebastian,项目名称:qgisplugin_spreadsheet,代码行数:8,代码来源:test_pyexcel_integration.py


示例9: test_auto_detect_int

 def test_auto_detect_int(self):
     sheet = pe.get_sheet(file_name=self.test_file, library="pyexcel-xls")
     expected = dedent("""
     pyexcel_sheet1:
     +---+---+-----+
     | 1 | 2 | 3.1 |
     +---+---+-----+""").strip()
     eq_(str(sheet), expected)
开发者ID:pyexcel,项目名称:pyexcel-xls,代码行数:8,代码来源:test_formatters.py


示例10: open_existing

 def open_existing(self, the_file):
     if not self.finished:
         sheet = get_sheet(file_name=the_file)
         for row in sheet.rows():
             self.row += row
         self.name_columns_by_row(0)
         self.name_rows_by_column(0)
         self._finished = True
开发者ID:michaelscales88,项目名称:automated_sla_tool,代码行数:8,代码来源:final_report.py


示例11: test_get_sheet_from_file

 def test_get_sheet_from_file(self):
     data = [["X", "Y", "Z"], [1, 2, 3], [4, 5, 6]]
     sheet = pe.Sheet(data)
     testfile = "testfile.xls"
     sheet.save_as(testfile)
     sheet = pe.get_sheet(file_name=testfile)
     assert sheet.to_array() == data
     os.unlink(testfile)
开发者ID:bdeeney,项目名称:pyexcel,代码行数:8,代码来源:test_signature_fuction.py


示例12: addExcel

def addExcel(path, nowtime):
    sheet = pe.get_sheet(file_name = path)
    
    oneRow = [nowtime]
    for i in range(1, len(sys.argv)):
        oneRow.append(sys.argv[i])
    sheet.row += oneRow
    sheet.save_as(path)
开发者ID:lumingliang,项目名称:bishe-node,代码行数:8,代码来源:createExcel.py


示例13: test_auto_detect_float_false

 def test_auto_detect_float_false(self):
     expected = [[
         '2014-12-25',
         '2014-12-25 11:11:11',
         '2014-12-25 11:11:11.000010']]
     sheet = pe.get_sheet(file_name=self.excel_filename,
                          auto_detect_datetime=False)
     self.assertEqual(sheet.to_array(), expected)
开发者ID:jayvdb,项目名称:pyexcel-io,代码行数:8,代码来源:test_pyexcel_integration.py


示例14: 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)
开发者ID:schulzsebastian,项目名称:qgisplugin_spreadsheet,代码行数:8,代码来源:test_multiline_feature.py


示例15: test_auto_detect_int

 def test_auto_detect_int(self):
     sheet = pe.get_sheet(file_name=self.test_file)
     expected = dedent("""
     pyexcel_sheet1:
     +---+---+-----+
     | 1 | 2 | 3.1 |
     +---+---+-----+""").strip()
     self.assertEqual(str(sheet), expected)
开发者ID:gamer-007,项目名称:pyexcel-xls,代码行数:8,代码来源:test_formatters.py


示例16: test_download

 def test_download(self):
     for file_type in FILE_TYPE_MIME_TABLE.keys():
         print(file_type)
         response = self.client.get("/polls/download/"+file_type)
         assert response['Content-Type'] == FILE_TYPE_MIME_TABLE[file_type]
         sheet = pe.get_sheet(file_type=file_type, file_content=response.content)
         sheet.format(int)
         array = sheet.to_array()
         assert array == self.data
开发者ID:hugutux,项目名称:django-excel,代码行数:9,代码来源:testResponse.py


示例17: load_single_sheet

 def load_single_sheet(self, field_name=None, sheet_name=None, **keywords):
     file_type, file_handle = self.get_file_tuple(field_name)
     if file_type is not None and file_handle is not None:
         return pe.get_sheet(file_type=file_type,
                             file_content=file_handle.read(),
                             sheet_name=sheet_name,
                             **keywords)
     else:
         return None
开发者ID:lchans,项目名称:ArcMembership,代码行数:9,代码来源:__init__.py


示例18: create_dictionary

def create_dictionary(sheet_list):
    '''
    creates allsheet_dict and ezsheet_dict
    '''

    for i in sheet_list:
        if i == './resources/All_output.xlsx':
            allsheet = pyexcel.get_sheet(file_name = sheet_list[0], name_columns_by_row=0)
            allsheet_od = allsheet.to_dict()#makes ordered dict
            allsheet_dict = dict(allsheet_od)#makes ordinary dict
            #print "ALL: ",allsheet_dict
        elif i == './resources/Easy_output.xlsx':
            ezsheet = pyexcel.get_sheet(file_name = sheet_list[1], name_columns_by_row=0)
            ezsheet_dict = dict(ezsheet.to_dict())
            #print "EZ: ",ezsheet_dict
        else:
            print "You don't have the appropriate sheet names"
    return (allsheet_dict, ezsheet_dict)
开发者ID:mipayne,项目名称:readability_project,代码行数:18,代码来源:modify_dictionary_from_excel_read.py


示例19: test_ods_output_stringio

 def test_ods_output_stringio(self):
     data = [[1, 2, 3], [4, 5, 6]]
     io = pyexcel.save_as(dest_file_type="ods", array=data)
     r = pyexcel.get_sheet(
         file_type="ods", file_content=io.getvalue(), library="pyexcel-ods3"
     )
     result = [1, 2, 3, 4, 5, 6]
     actual = list(r.enumerate())
     eq_(result, actual)
开发者ID:pyexcel,项目名称:pyexcel-ods3,代码行数:9,代码来源:test_stringio.py


示例20: test_get_sheet_from_memory_compatibility

 def test_get_sheet_from_memory_compatibility(self):
     data = [
         ["X", "Y", "Z"],
         [1, 2, 3],
         [4, 5, 6]
     ]
     content = pe.save_as(dest_file_type="xls", array=data)
     sheet = pe.get_sheet(content=content.getvalue(), file_type="xls")
     assert sheet.to_array() == data
开发者ID:ChiangFamily,项目名称:pyexcel,代码行数:9,代码来源:test_signature_fuction.py



注:本文中的pyexcel.get_sheet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyexcel.load函数代码示例发布时间:2022-05-25
下一篇:
Python pyexcel.get_dict函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap