Python Forum
KeyError issue - unable to find root cause
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KeyError issue - unable to find root cause
#10
So I assume you download it as csv and then pass the path/filename as argument
read_file function will not work in this case because it expects json, not csv file
so best is to use csv module
import requests
import sys,os
import datetime
import json,time
from functions import read_file,getdate
from functions import getcurrentdate,constructJson_Request
from functions import postURL,send_mail
import csv
 
currentdate = getcurrentdate()
 
config_filepath = os.getcwd()+"/configuration.json"
configuration = read_file(config_filepath,"configuration")

with open(sys.argv[1]) as workorder_file:
    rdr = csv.DictReader(workorder_file)
    for req in rdr:
        send_to = req['emailid']
        subject = "Request ID:" + req['workorderid'] + " - Reminder 1"
        text = "Request ID:" + req['workorderid'] + " - Reminder 1"
        resp = send_mail(configuration, send_to, subject, text)
        print("Mail Sent" + resp)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: KeyError issue - unable to find root cause - by buran - Aug-30-2018, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to find module in su mode? korenron 2 2,023 Jan-10-2021, 07:41 PM
Last Post: Gribouillis
  Cant find root cause of thread.lock error burlyboys 0 1,601 May-18-2020, 12:51 PM
Last Post: burlyboys
  Unable to find an existing module arbiel 2 5,106 Apr-11-2020, 07:12 PM
Last Post: arbiel
  unable to pass a input after changing the user from root to non root using python avinash 3 3,278 Apr-08-2019, 10:05 AM
Last Post: avinash
  How to ignore - ERROR: The system was unable to find the specified registry key or va asheru93 9 6,889 Feb-04-2019, 06:35 AM
Last Post: asheru93
  unable to find vcvarsall.bat nithya 1 4,091 Jan-03-2018, 08:25 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020