How to use invoke power shell to run python script which need a parameter

Hello everybody,

The following are the details of my codes, is there anyone could help me ? Thanks in advance!

#!/usr/bin/python

-- coding: UTF-8 --

import pandas as pd #invoke pandas sort the excel
from openpyxl import load_workbook #Access excel workbook
import datetime #Custom Date Format in excel
import sys

def sort_by_po(unfinishedExcelPath):
file = pd.DataFrame(pd.read_excel(unfinishedExcelPath))
book = load_workbook(unfinishedExcelPath)
writer = pd.ExcelWriter(unfinishedExcelPath,
engine=‘openpyxl’)
writer.book = book
writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
file.sort_values(by=[‘PO’,‘Item’,‘Delivery Date’],ascending=[True,True,True], inplace=True)
file.to_excel(writer, sheet_name=‘Sheet1’, index=False)
writer.save()
file = load_workbook(unfinishedExcelPath)
ws = file.active
for i in range(2,ws.max_row+1):
new_value = ws.cell(row=i,column=6).value.strftime(‘%Y-%m-%d’)
ws.cell(row=i, column=6,value=new_value)
file.save(unfinishedExcelPath)

if name == ‘main’:
sort_by_po(sys.argv[1])

Hi @yu.xingxing,
I know that it might be something obvious and I’m not sure if this applicable to your case but remember that indexes usually starts from number “0”. The error you have is telling something about out of index range. Maybe that’s the case here.