Python Forum

Full Version: Some direction needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I am new to the python world and am about to embark on my first project. What I am trying to do is essentially replicate a excel macro. I am not using a macro because I have multiple workbooks I need to manipulate. I do know I want to use Pandas to complete this task but being my first time I am a little uncertain of things. Below are the first few steps I need to replicate.

insert a blank column after column P (after the IPPER Plan Code (CBF)column).
Call the column CON/PLAN.
Populate the formula =N14&P14 into cell Q2 of the column. Drag the formula down to populate all cells in the column.
NOTE: Clear contents in #3 below. In FIN_Find_Customer_Invoices_lines_with_Worktags.xlsx, copy the the data from row 13 to bottom.
Go to the current month Custom excel, Worksheet tab. Paste in the copied data (not as values). You will over-write the tab. Make sure columns E, F, and G are formatted as dates in the updated Worksheet tab.
Close the FIN_Find_Customer_Invoices_lines_with_Worktags.xlsx.

Here is what I am starting with:

import pandas as pd
file_name = C:\Users\u678153\Desktop\FIN_Find_Customer_Invoices_lines_with_Worktags.xlsx
df = pd.read_excel(file_name) #Read Excel file as a DataFrame
I would appreciate any guidance
No one?
I was actually able to insert the new column using
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile

df = pd.read_excel('C:/Users/u678153/Desktop/FIN_-_Find_Customer_Invoices_Lines_with_Worktags.xlsx', sheet_name='Detail', skiprows=12)
df.insert(15, 'CON/PLAN', '')

df.to_csv('C:/Users/u678153/Desktop/test.csv')
A bit of a challenge when we have no access to the spreadsheet, so here goes.
insert a blank column - please google "python pandas insert column" and follow instruction that appear
rename the column: How to rename

And really for the rest of it you need some pandas knowledge. I suggest putting this aside for a minute and doing one or 2 tutorials. Might start with Tutorials point Python Pandas