Tag: python

Converting CSV to XLSX using openpyxl, but quote comes infront of numbers

I tried to convert CSV to xlsx using openpyxl. The conversion was successful but i noticed quote (‘) in-front of numbers. Making it string instead of numbers. As I am new to python you help would be grateful. Here is code I am using: import os import glob import csv import openpyxl for csvfile in […]

How to search an xlsx file for a specific string using Python (and perhaps openpyxl)

How can I search an xlsx file for a specific string variable? Example: ORIGINAL TEXT FILE: one – a b c two – a b c three – a b c four – a b c five – a b c XLSX FILE: two three five OUTPUT CSV FILE: The following in two columns: two […]

Writing to Excel based on row values

I have an Excel file that looks like this (Col4 values are not letters, but names): col1 col2 col3 col4 —————————– row1 | 2,3,1 _ 1 w row2 | 3,2,7 _ 2 x row3 | _ _ 3 y row4 | 4,9 _ 4 z I want to write some values in column 2 that […]

Dealing with Nested Loops in Python – Options?

I have a function that looks like this (below). I’m using xlrd in python. Whenever I perform the “print path” function, I receive way too many iterations of path. Essentially, what I’m trying to do is compare two columns in excel, and print out a third. That works perfectly, except that the third is printed […]

Copied Excel Files losing Web query

I’m using Python and the module openpyxl. I have been able to: CreateFile = openpyxl.load_workbook(filename= ‘OldWorkbook.xlsm’, keep_vba = True) Sheet = CreateFile.active Sheet[‘A1’]=(“What Ever You Want”) CreateFile.save(‘NewWorkbook.xlsm’) But when I open the NewWorkbook the web query I defined in OldWorkbook is not there in NewWorkbook, any suggestions?

Run Macro Win32com with python, Filename Excel Spaces issue

I had a issue with running a macro from an excel with python/flask. When the file don’t have spaces on his name works okay and run the macro, if the file have spaces in the filename i can’t run it. Here’s the code of the py file app.route(‘/process_done’, methods=[‘POST’]) def runmacros(): run_macro(“Main System FIndx.xlsm!Test_macro.Prueba”,”..\System\Main Test.xlsm”) […]

How do I apply conditional formatting on a pair of rows in Excel?

I am using Python and xlwings to insert data in an excel worksheet. The data looks like below in excel: A B C D E 1 10 20 5 15 30 2 15 10 12 15 20 3 Empty 4 22 11 5 8 9 5 10 5 12 2 9 6 Empty My aim […]

Why is my csv writer writing in columns not rows?

My csv writer is writing in columns not rows am I doing something wrong? Python 3.5 code: def create_csv(finished_file): csv_data = [] header = [“Parcel Number”] csv_data.append(header) csv_data.append(parcel_codes) resultFile = open(finished_file+”.csv”,’w+’) wr = csv.writer(resultFile) wr.writerows(csv_data) resultFile.close() It was working before – I did upgrade to excel 2016 but that should not make a difference. And […]

How to copy multiple rows and one column from one CSV file to another CSV Excel?

I am extremely new to python(coding, for that matter). Could I please get some help as to how can I achieve this. I have gone through numerous threads but nothing helped. My input file looks like this: I want my output file to look like this: Just replication of the first column, twice in the […]

Using openpyxl to swap rows

I have a spread sheet of objects, a new value for these objects is generated every day and saved in a new cell along side the old ones. I want to create a new sheet and order my objects by the size of the value given that day. I can write the code to sort […]

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