xlrd

editing existing excel workbook using xlrd, xlwt and xlutils

[亡魂溺海] 提交于 2019-12-11 12:08:46
问题 How to edit and save the data in an existing excel workbook using xlrd, xlwt and xlutils module? could someone please provide a sample code to edit and save the data in excel workbook? I am trying to put data from one workbook to another. import xlrd, xlwt, xlutils wb1 = xlrd.open_workbook('workbook1.xls', formatting_info=True) wb2 = xlrd.open_workbook('workbook2.xls', formatting_info=True) value 1 == wb2.sheet_by_name('Sheet1).cell(2,1).value wb1.sheet_by_name('Sheet1').cell(2,2).value ==

Python/Excel - IOError: [Errno 2] No such file or directory:

独自空忆成欢 提交于 2019-12-11 10:51:57
问题 Attempting to extract .xlsx docs from a file and compile the data into a single worksheet. Receiving a IOError despite that the files exist Program is as follows #-------------- loop that pulls in files from folder-------------- import os #create directory from which to pull the files rootdir = r'C:\Users\username\Desktop\Mults' for subdir, dir, files in os.walk(rootdir): for file in files: print os.path.join(subdir,file) #----------------------merge work books----------------------- import

Error while using QUOTE_NONE to never quote fields while writing to csv

a 夏天 提交于 2019-12-11 10:43:05
问题 I've written a simple code in python using xlrd module that reads data from xlsx file and writes it to csv. When I try to write to csv with no fields I'm getting below error: Error: need to escape, but no escapechar set with reference to question 23296356 on so, I've tried setting quotechar to empty string to fix the error.But that did not fix the issue. What I'm I missing here? Below the code snippet that I've be running: import xlrd import csv wb=xlrd.open_workbook('testfile.xlsx') lisT =

Writing to existing workbook

ぐ巨炮叔叔 提交于 2019-12-11 08:58:11
问题 I was wondering if someone could help me out with this. I want to make changes to an existing .xls file using xlwt/xlrd/xlutils. I took a look at this question and tried the two answers at the bottom of the page. When I tried the second answer, I got this error: AttributeError: 'Sheet' object has no attribute 'cooked_page_break_preview_mag_factor' When I tried the third answer, I got this error: AttributeError: 'str' object has no attribute 'datemode' The files I'm using are exactly the same

Data Type Conversion Error while trying to dynamically add columns(fields) from excel in MS-Access database using Python

放肆的年华 提交于 2019-12-11 07:50:08
问题 I'm trying to populate the 1st row(i.e. the column names) from an excel sheet to the ms-access database, but it's giving me ' Data type conversion Error(3421) '. Any idea why this is happening ? from comtypes.client import CreateObject from xlrd import open_workbook,cellname import os from comtypes.gen import Access access = CreateObject('Access.Application') DBEngine = access.DBEngine db = DBEngine.CreateDatabase('test.mdb', Access.DB_LANG_GENERAL) excel_file = open_workbook('test_excel_file

How to delete an existing worksheet in excel file using xlutils, xlwt, xlrd with python

我怕爱的太早我们不能终老 提交于 2019-12-11 06:39:54
问题 I tried to search many places but dit not see any example snippet of code about how to delete an existing worksheet in excel file by using xlutils or xlwt with python. Who can help me, please? 回答1: I just dealt with this and although this is not generally a good coding choice, you can use the internal Workbook _worksheets to access and set the worksheets for a workbook object. write_book._Workbook__worksheets = [write_book._Workbook__worksheets[0]] this would strip everything but the first

Python 3.4 pip install

笑着哭i 提交于 2019-12-11 05:51:33
问题 I am trying to install the xlrd module on my Mac, however when I open IDLE and import the xlrd module, I get the error: Input Error: No module named xlrd To install it, I used in my home directory... sudo pip install xlrd ... and it is installed successfully. Note that I have both Python 2.7 and Python 3.4.0 on my computer, in case this is what is causing problems. I want it installed for Python 3.4.0. 回答1: To avoid conflicts between parallel Python 2 and Python 3 installations, only the

UnicodeEncodeError with xlrd

纵饮孤独 提交于 2019-12-11 04:34:45
问题 I'm trying to read a .xlsx with xlrd. I have everything set up and working. It works for data with normal English letters as well as numbers. However when it gets to Swedish letters (ÄÖÅ) it gives me this error: print str(sheet.cell_value(1, 2)) + " " + str(sheet.cell_value(1, 3)) + " " + str(sheet.cell_value(1, 4)) + " " + str(sheet.cell_value(1, 5)) UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 1: ordinal not in range(128) My code: # -*- coding: cp1252 -*-

Validating a cell value using XLRD

白昼怎懂夜的黑 提交于 2019-12-11 02:38:42
问题 I am trying to use the package XLRD to read the value of row 2(row 1 in excel), in particular column A. I know that the value is "text:u'NULL'" but if I try to write an if function which compares a variable which I have given the same value, it does not recognise them as the same. (Just to explain my spreadsheet has the value Null in the cell I am referring to but using XLRD it reads this as "text:u'NULL'" which is fine) I have created a test example of what I am referring to as this is hard

Import excel time into Pandas with decimal seconds

纵然是瞬间 提交于 2019-12-11 02:33:59
问题 I have an excel spread sheet (.xls) that contains a time column. The time is displayed in Excel as minutes:seconds.tenths of seconds. Such as "50:59.2" "50:59.4". The raw data contains hours:minutes:seconds.decimalseconds. When I import the data into pandas I am loosing the tenths of a second: indata=pd.read_excel('Data.xls','Tabular Data',header=9,skiprows=[1,2,3,4,5,6,7,8,10,11,12]) indata['Time'] 0 17:50:59 1 17:51:00 2 17:51:00 3 17:51:00 ... indata.Time[0].microsecond 0 indata.Time[1]