Run python code issue

Hi Team,

I am trying to run below python code using Run Python Script method in Python Scope activity.But I am getting error. Error is attached in the screenshot and pfb the python code

Global Fund Coverage Ratio Report Automation

import pyodbc #loads the library which make database connection possible
from datetime import datetime #allows dynamic naming of files to avoid overwrite
import csv #loads the library for reading the regions and countries file we want
cnxn = pyodbc.connect(driver=‘{SQL Server}’,server=‘sznsqadb01’,database=‘RawData’,UID=‘DataClient’,PWD=‘GetData2’) #connects to the database
cursor=cnxn.cursor()

now = datetime.now()
datestr = str((now.year10000)+(now.month100)+now.day)
SelPlaceFile = ‘V:\Data\OE Data Team\Fund Coverage\Active\Selected Regions and Countries.csv’

places =
placereader = csv.reader(open(SelPlaceFile,‘rt’), delimiter=‘,’)
for row in placereader:
places.append(row)

def uniques(seq):
rset = set(seq)
return list(rset)

placeregion =
for row in places:
placeregion.append(row[2])

placeregion = uniques(placeregion)

domicileselect = “CASE”
for row in placeregion:
domicileselect = domicileselect + " WHEN a.Domicile IN("
domswarea =
for item in places:
if item[2]==row: domswarea.append(item[0])
domicileselect = domicileselect +“'”+“','”.join(domswarea)+“'”+“) THEN '”+row+“'”
domicileselect = domicileselect + " ELSE a.Domicile END,"

cursor.execute(“”“Select
Domicile=”“”+domicileselect+
“”“SecurityType,
Total=SUM(case when FundClassId is not null then 1 else 0 end),
IdReady=SUM(case when DDataReadiness in (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31) then 1 else 0 end),
OperReady=SUM(case when DDataReadiness in (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31) then 1 else 0 end),
PriceReady=SUM(case when VDataReadiness in (8,9) then 1 else 0 end),
PerfReady=SUM(case when VDataReadiness =9 then 1 else 0 end),
AllReady=SUM(case when (DDataReadiness in (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)
and DDataReadiness in (2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31) and VDataReadiness =9) then 1 else 0 end)
from (
SELECT v.Domicile as Domicile,
v.FundClassId as FundClassId,
case when v.SecurityType=‘-’ and v.LegalStructureId=‘39’ then ‘SIMCAV’
when v.SecurityType=‘SA’ and s.SAType in (1,4) then ‘SA’
when v.SecurityType=‘SA’ and s.SAType=2 then ‘CIT’
when v.SecurityType=‘SA’ and s.SAType is null then ‘IGSA’
else v.SecurityType end as SecurityType,
v.DataReadiness as VDataReadiness,
d.DataReadiness as DDataReadiness,
v.PerfReady
from ViewSecurityTypeBaseTable v
left join ViewDataStatus d on d.Id=v.FundClassId
left join ViewFundShareClass s on s.Id=v.FundClassId
left join (Select FundClassId,ShareClassTypeId from ViewSecurityTypeBaseTable where ShareClassTypeId=‘10000’) sc on sc.FundClassId=v.FundClassId
where v.SecurityType!=‘XI’
and sc.ShareClassTypeId is null
and v.Status = 1) a
GROUP BY Domicile, SecurityType
ORDER BY SecurityType, Domicile”“”)

queryrecs = cursor.fetchall()

summarydata = queryrecs

cnxn.close()

FILE = open(‘V:\Data\OE Data Team\Fund Coverage\Investment Counts Export ‘+datestr+’.csv’,‘w’)
FILE.write(‘Domicile,SecurityType,Total,IDReady,OperReady,PriceReady,PerfReady,AllReady’+‘\n’)

for row in summarydata:
FILE.write(str(row)[1:len(str(row))-1].replace(‘'’,‘’)+‘\n’)

FILE.close()

print('File saved as '+‘V:\Data\OE Data Team\Fund Coverage\Investment Counts Export ‘+datestr+’.csv’)
print(‘Done.’)

Kindly help me to resolve this issue

Hi @sshitol

One thing I can comment on right away is that the field you are trying to fill in takes a string as an argument:
image

This means that your script will need to be between two quotation marks:

""

I would still suggest to simply give the path to the script first to test instead over here:

image