Tag: python

Incrementing Excel row in python

So I have tried a few different ways to get this to work, none have prevailed. worksheet.merge_range(‘B4:D4′, testStr) This is the function to merge cells in excel. I have this inside a loop and want to be able to increment the 4 based on the value in the loop. i = 5 worksheet.merge_range(“B’%s’:D’%s'”, testStr) % […]

python-excel mismatch on defaults

Python and Excel have a different behaviour for defaults. Python is passing optional arguments by keyword, while Excel is only positional, even on defaults. As a result, an unused argument is in reality passed, as None. Assuming as example the scipy function brentq: brentq(f, a, b, xtol=1e-12, rtol=4.4408920985006262e-16, maxiter=100, full_output=False, disp=True, *args) calling it from […]

how do I disply an np.array in column with xlwings

I have the following code in python with xlwings @xlfunc @xlarg(‘x’, ‘nparray’, ndim=1) @xlarg(‘y’, ‘nparray’, ndim=1) def test_sum(x,y): return(x+y) Once in excel, I submit ctrl+shift+Enter but it displays the result in a line and not in column. How can I correct this ?

How to format this data to a csv friendly format in python

Relatively simple question, I have this market data http://pastebin.com/HmiMbux5 in the form [[‘data’,high, open, low, close, volume, etc],[‘data’,high, open, low, close, volume, etc]] However when saving the .txt file as a .csv and loading into excel it puts all the data in the top row. What python code can I use to take [data],[data] and […]

Using Python to Print Folder Sizes from Directory into CSV or Excel File

I currently have the python script to “print” the folder sizes of a directory in cmd. This works well. import locale import os locale.setlocale(locale.LC_ALL, “”) def get_size(state, root, names): paths = [os.path.realpath(os.path.join(root, n)) for n in names] # handles dangling symlinks state[0] += sum(os.stat(p).st_size for p in paths if os.path.exists(p)) def print_sizes(root): total = 0 […]

What's the best way to manipulate excel data in Python

I want to import an excel spread sheet into Python so I can then manipulate the data, how do I got about this?

Cannot save output to Excel Workbook when Python fills the data

When I run the following code everything works find: wb7 = load_workbook(‘define2.xlsx’) ws = wb7.worksheets[0] ws.cell(row=3,column=2).value = “hey” wb7.save(‘define2.xlsx’) But when I put the final line of code at the end of a different code I get an error message. And the error is generated right as I step over the line: wb7.save(‘define2.xlsx’) The error […]

Appending formula text to specific cell on pandas

I have a python app which runs 4 queries and writes results to excel file. Everything works fine but i can’t find a way to append formula text into specific cell with sheetname. Here is my code: import pandas as pd import pyodbc df = pd.read_sql_query(script, cnxn) df2 = pd.read_sql_query(script2, cnxn) df3 = pd.read_sql_query(script3, cnxn) […]

Attempting to make a multi-column graph

I am trying to make a column graph where the y-axis is the mean grain size, the x-axis is the distance along the transect, and each series is a date and/or number value (it doesn’t really matter). I have been trying a few different methods in Excel 2010 but I cannot figure it out. My […]

How to correct the encoding while creating excel file from 'utf-8' data using python

I am trying to create an excel file using python from a list of dictionaries. Initially I was getting an error of improper encoding. So I decoded my data to ‘utf-8‘ format. Now after the creation of excel, when I checked the values in each field, their format has been changed to text only. Below […]

MS Excel Spreadsheet is the best Office Software, Excel VBA and Excel Formulas make Spreadsheet work faster.