Tag Archives: python

Data Nitro and regular expression (Python)

Questions: I have this column in MS Excel 2010 – which has a combination of ‘zip code’ and ’email-ids’ I am trying to extract these zip-codes(20530, 90012-3308 etc.) from this column. 20530 mark@ucvxcx.gov 20530 kidafd@gmail.com 20530 vladfeodsaf@usdodfaadj.govv 20530 syadfadsbil.vvbvx@vnvnvn.gov 20004 safdbnvis9dfg@infdda.gov 20530 vhlhsdlf8dlfha@vbvbcxbUI.GOV 90012-3308 h.james@asdfad.gov 90012-3308 madsfl.hjlkdjd@pkdoi.gov 90012 mark.fraser@ruskgb.zx I tried Python’s re module. import… Read More »

Compare 2 excel files using Python

Questions: I have two xlsx files as follows: value1 value2 value3 0.456 3.456 0.4325436 6.24654 0.235435 6.376546 4.26545 4.264543 7.2564523 and value1 value2 value3 0.456 3.456 0.4325436 6.24654 0.23546 6.376546 4.26545 4.264543 7.2564523 I need to compare all cells, and if a cell from file1 != a cell from file2 print that. import xlrd rb… Read More »

Python to delete a row in excel spreadsheet

Questions: I have a really large excel file and i need to delete about 20,000 rows, contingent on meeting a simple condition and excel won’t let me delete such a complex range when using a filter. The condition is: If the first column contains the value, X, then I need to be able to delete… Read More »

How do I run excel using all the default add-ins from Python win32com

Questions: import win32com import win32com.client as win32 xl = win32.gencache.EnsureDisplatch(‘Excel.Application’) This fires up Excel, but for whatever reason none of the plugins load. If Excel was already loaded, the plugins will stay loaded and be accessible. Please advise. Context: I’m scraping data from a worksheet that makes calls using a proprietary plugin. If the plugin… Read More »

Embedding excel into a gui, for a python program

Questions: I’m writing a python(3) program that will run on windows only. The program should have a GUI that contains, in part of its window, an embedded excel workbook (and not just its data). Is there a way of doing so with wxPython/PyQt/other? If not, I found a way of doing that in c#, so… Read More »

Python: Script for running Excel VBA script not running

Questions: I am writing because after seemingly searching half the internet, I could not figure out why this simple piece of code is not working: from win32com.client import Dispatch def RunExcelMacro(name): myExcel = Dispatch(‘Excel.Application’) myExcel.Visible = 0 myExcel.Workbooks.Add(‘C:\AC_Software\TestDatei.xls’) myExcel.Run(name) myExcel.DisplayAlerts = 0 myExcel.Quit() if __name__ == “__main__”: RunExcelMacro(‘Makro_test’) It is supposed to run the vba… Read More »

Setting excel column styles in python (xlwt)

Questions: I’m trying to write data to an excel document, some of the columns consist entirely of date/numeric data that I want to format. I could set a format on each cell individually, but that seems excessive. There’s a set_style method on the column, object, but for some reason it doesn’t seem to do anything.… Read More »

How could I set up the height of cell to auto with Python xlwt

Questions: I would like to put the variable length text to an Excel file – some text are shorten, and another are longer. These cells are one above the other, so the width of cells are equal. I’m trying to do this: sheet.row(rownr).height = 0 with combination if sheet.row(rownr).height_mismatch = True The first line produces… Read More »

python pandas read_excel returns UnicodeDecodeError on describe()

Questions: I love pandas, but I am having real problems with Unicode errors. read_excel() returns the dreaded Unicode error: import pandas as pd df=pd.read_excel(‘tmp.xlsx’,encoding=’utf-8′) df.describe() ————————————————————————— UnicodeDecodeError Traceback (most recent call last) … UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc2 in position 259: ordinal not in range(128) I figured out that the original Excel had… Read More »