xlrd

Extracting Hyperlinks From Excel (.xlsx) with Python

痴心易碎 提交于 2019-12-18 05:48:15
问题 I have been looking at mostly the xlrd and openpyxl libraries for Excel file manipulation. However, xlrd currently does not support formatting_info=True for .xlsx files, so I can not use the xlrd hyperlink_map function. So I turned to openpyxl, but have also had no luck extracting a hyperlink from an excel file with it. Test code below (the test file contains a simple hyperlink to google with hyperlink text set to "test"): import openpyxl wb = openpyxl.load_workbook('testFile.xlsx') ws = wb

Reading Excel file is magnitudes slower using openpyxl compared to xlrd

时间秒杀一切 提交于 2019-12-17 23:30:05
问题 I have an Excel spreadsheet that I need to import into SQL Server on a daily basis. The spreadsheet will contain around 250,000 rows across around 50 columns. I have tested both using openpyxl and xlrd using nearly identical code. Here's the code I'm using (minus debugging statements): import xlrd import openpyxl def UseXlrd(file_name): workbook = xlrd.open_workbook(file_name, on_demand=True) worksheet = workbook.sheet_by_index(0) first_row = [] for col in range(worksheet.ncols): first_row

Format individual characters in a single Excel cell with python

笑着哭i 提交于 2019-12-17 19:43:31
问题 I am using xlrd, xlwt, and xlutils on the Windows Vista OS with Python 2.7. I have a set of DNA sequences in an excel worksheet that are 100 characters long, with each sequence in a single cell. I am trying to highlight characters at specific positions within each of these sequences in excel (bold them or change color), but have not found a way to format individual characters within a cell. Applying a style applies it to the entire cell to my knowledge. Therefore I am trying to break the

How do I find the formatting for a subset of text in an Excel document cell

两盒软妹~` 提交于 2019-12-17 18:56:06
问题 Using Python, I need to find all substrings in a given Excel sheet cell that are either bold or italic. My problem is similar to this: Using XLRD module and Python to determine cell font style (italics or not) ..but the solution is not applicable for me as I cannot assume that the same formatting holds for all content in the cell. The value in a single cell can look like this: 1. Some bold text Some normal text. Some italic text . Is there a way to find the formatting of a range of characters

Identifying Excel Sheet cell color code using XLRD package

纵然是瞬间 提交于 2019-12-17 09:33:01
问题 I am writing a python script to read data from an excel sheet using xlrd. Few of the cells of the the work sheet are highlighted with different color and I want to identify the color code of the cell. Is there any way to do that ? An example would be really appreciated. 回答1: Here is one way to handle this: import xlrd book = xlrd.open_workbook("sample.xls", formatting_info=True) sheets = book.sheet_names() print "sheets are:", sheets for index, sh in enumerate(sheets): sheet = book.sheet_by

python xlrd unsupported format, or corrupt file.

旧街凉风 提交于 2019-12-17 04:34:10
问题 My code: import xlrd wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls") sh = wb.sheet_by_index(0) print sh.cell(0,0).value The error: Traceback (most recent call last): File "Z:\Wilson\tradedStockStatus.py", line 18, in <module> wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls") File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 429, in open_workbook biff_version = bk.getbof(XL_WORKBOOK_GLOBALS) File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1545,

python xlrd unsupported format, or corrupt file.

江枫思渺然 提交于 2019-12-17 04:33:11
问题 My code: import xlrd wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls") sh = wb.sheet_by_index(0) print sh.cell(0,0).value The error: Traceback (most recent call last): File "Z:\Wilson\tradedStockStatus.py", line 18, in <module> wb = xlrd.open_workbook("Z:\\Data\\Locates\\3.8 locates.xls") File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 429, in open_workbook biff_version = bk.getbof(XL_WORKBOOK_GLOBALS) File "C:\Python27\lib\site-packages\xlrd\__init__.py", line 1545,

writing to existing workbook using xlwt [closed]

走远了吗. 提交于 2019-12-17 02:21:38
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I am unable to find examples where xlwt is used to write into existing files. I have a existing xls file that I need to write to. When I use xlrd to read the file, I cant seem to figure out how to transform the "Book" type returned into a xlwt.Workbook. I would appreciate if someone can point me to an example. 回答1

Eclipse XLRD, XLWT Import Error

ぐ巨炮叔叔 提交于 2019-12-13 19:59:43
问题 I downloaded the latest Enthought EPD python distribution (academic), which comes with python 2.7. I am using Eclipse as my IDE. Eclipse is set up to use this instance of Python. I ran the "images.py" example file under XLWT. "images.py": from xlwt import Workbook w = Workbook() ws = w.add_sheet('Image') ws.insert_bitmap('python.bmp', 0, 0) w.save('images.xls') and Eclipse returned: Traceback (most recent call last): File "C:\Documents and Settings\Username\workspace\XLRDXLWT\src\xlwt\images

How to extract data from excel in specific format & how to store in Database

陌路散爱 提交于 2019-12-13 08:49:22
问题 I have excel file shown bellow from that i need to extract data in different format using python. so please help i tried the bellow code: import xlrd book = xlrd.open_workbook("excel.xlsx") sheet = book.sheet_by_index(0) year=[] # for print the year seperately in list. for dat in sheet.row_values(0): if dat is not '': year.append(dat) print(year) rowdata = [] for i in range(2, sheet.nrows): sheetinlist = sheet.row_values(i) for cell in sheetinlist: if cell is not '': rowdata.append(cell)