xlrd

why is my python code returning text:'my string' instead of just my string?

强颜欢笑 提交于 2019-12-13 05:11:44
问题 my code snippet looks like this: for current_row in range(worksheet.nrows): fname_text = worksheet.row(current_row)[0] lname_text = worksheet.row(current_row)[1] cmt = worksheet.row(current_row)[2] print (fname_text, lname_text, cmt) this prints: text:'firstname' text:'lastname' text'the cmt line' i want it just to return: firstname lastname the cmt line what do i need to change to make this happen? 回答1: That's what Cell objects look like: >>> sheet.row(0) [text:u'RED', text:u'RED', empty:'']

Python - Excel: Finding the first empty row in a column

拟墨画扇 提交于 2019-12-13 04:25:57
问题 working from my last question I've managed to get a good chunk of the way to get my system finished. Of course I've run across a problem. I basically have a program that plays a game. Every correct answer adds 10 to the global variable 'points'. Then I want to add 'points' into an excel spreadsheet. This is where I get very stuck. I'm running XLRD-0.8.0, XLUTILS-1.4.1 and XLWT-0.7.5. Of course I've looked up different things but they don't seem to work for me. This is a simplified version of

data extraction from xls using xlrd in python

最后都变了- 提交于 2019-12-13 00:40:58
问题 I am trying to extract the data from an .xls file and making a list but i am getting the list as [u'elem1', u'elem2', u'elem3'] , but if i print separately i get as: elem1 elem2 elem3 what is that u thing and how to remove it? Here is my code... from xlrd import open_workbook xls=open_workbook('name.xls') for sheets in xls.sheets(): list1=[] for col in range(sheets.ncols): for rows in range(sheets.nrows): list1.append(sheets.cell(rows, col).value) print(list1) for i in list1: print(i) 回答1:

Force selenium to pause and wait for a field to be available

浪尽此生 提交于 2019-12-12 14:09:53
问题 Below is a snippet of code from my python script that is reading an excel file and assigning cells in a row to a variable that is then used to be typed into a field in the browser. it works great ... for the most part. what i would like to do is setup some sort of loop after the browser loads the page to do the following: find the element by some ID. if this fails, wait 5 seconds then try again. if it succeeds carry on with the rest of the script. now go easy on me, this is my first real

OpenPyXL always return None for a cell with hyperlink

倾然丶 夕夏残阳落幕 提交于 2019-12-12 10:14:12
问题 (My ultimate purpose is to append clickable cells to existing XLSX .) I use the code below to extract the cell's display value and the hyperlink. from openpyxl import load_workbook xlsFile='hello.xlsx' wbook = load_workbook(xlsFile) wsheet1= wbook.get_sheet_by_name('mysheet') cell1 = wsheet1.cell('A1') print cell1.value print cell1.hyperlink print wsheet1['A1'].value print wsheet1['A1'].hyperlink But it returns the following things: URL1 None URL1 None Why the hyperlink always None ? I did

AssertionError with pandas when reading excel

拥有回忆 提交于 2019-12-12 05:36:25
问题 I'm trying to read an xlsx file into python using pandas. I've done this thousands of times before but some reason it is not working with a particular file. The file is downloaded from another source and I get an AssertionError (see end) when reading with pandas: df = pandas.read_excel(pathtomyfile, sheetname = "Sheet1") The variable is defined for the path. The path exists (os.path.exists(path) returns True). When I copy the contents of the file and paste the values in a new excel doc, this

Python Excel - How to turn sheet name into sheet number

喜欢而已 提交于 2019-12-12 03:06:25
问题 In this program I create a sheet on the input excel file called new_sheet. I need the sheet number of the sheet without having to look at the excel file. How do I return the sheet number from the program? import xlwt import xlrd import csv workbook = xlrd.open_workbook('input.xls') worksheet = workbook.add_sheet('new_sheet') 回答1: I'm not understand well if you want count how many sheets there are in your Excel file or if you want know, gave the name of sheet at which number correspond; anyway

Error with xlrd and open_woorkbook

ぐ巨炮叔叔 提交于 2019-12-12 01:39:19
问题 I´m starting programming with python and I keep receiving the same error in this program: import xlrd import numpy as np import matplotlib as plt file_location = " X:\ \blabla.xlsx" import workbook wb=xlrd.open_workbook(filename= 'blabla.xlsx') Traceback (most recent call last): File "", line 1, in AttributeError: module 'xlrd' has no attribute 'open_workbook' The paths are well written and I don´t have more than one xlrd module, which I looked up trough help function: help(xlrd) Help on

Writing a list to new excel xlsx with dataframes

浪尽此生 提交于 2019-12-11 17:42:06
问题 I am having some trouble finding the best way to write a list to a loaded excel sheet and then saving the result as an xlsx. What I want my code to do is to take the lists that I have created and put them in specific columns of the loaded workbook. I think there is probably an easier way to do this using dataframes, but I do not know how. Ideally, I would like to save the formatting of the loaded workbook. col_test = [1L, 2L, 3L, 4L, 5L] My code is this import xlrt from xlrd import open

pyExcelerator or xlrd - How to FIND/SEARCH a row for the given few column data?

醉酒当歌 提交于 2019-12-11 12:36:14
问题 Python communicating with EXCEL... i need to find a way so that I can find/search a row for given column datas. Now, i m scanning entire rows one by one... It would be useful, If there is some functions like FIND/SEARCH/REPLACE .... I dont see these features in pyExcelerator or xlrd modules.. I dont want to use win32com modules! it makes my tool windows based! FIND/SEARCH Excel rows through Python.... Any idea, anybody? 回答1: @John Fouhy: [I'm the maintainer of xlwt, and author of xlrd] The