代码拉取完成,页面将自动刷新
# Example
# Import job applications from a CSV File (created via Google Forms) to "Job Application"
import csv
from frappeclient import FrappeClient
NAME = 2
EMAIL = 3
INTRODUCTION = 4
THOUGHTS_ON_COMPANY = 5
LIKES = 6
LINKS = 7
PHONE = 8
def sync():
print("logging in...")
client = FrappeClient("https://xxx.frappecloud.com", "xxx", "xxx")
with open("jobs.csv", "rU") as jobsfile:
reader = csv.reader(jobsfile, dialect='excel')
for row in reader:
if row[0]=="Timestamp":
continue
print("finding " + row[EMAIL])
name = client.get_value("Job Applicant", "name", {"email_id": row[EMAIL]})
if name:
doc = client.get_doc("Job Applicant", name["name"])
else:
doc = {"doctype":"Job Applicant"}
doc["applicant_name"] = row[NAME]
doc["email_id"] = row[EMAIL]
doc["introduction"] = row[INTRODUCTION]
doc["thoughts_on_company"] = row[THOUGHTS_ON_COMPANY]
doc["likes"] = row[LIKES]
doc["links"] = row[LINKS]
doc["phone_number"] = row[PHONE]
if doc.get("status") != "Rejected":
doc["status"] = "Filled Form"
if name:
client.update(doc)
print("Updated " + row[EMAIL])
else:
client.insert(doc)
print("Inserted " + row[EMAIL])
if __name__=="__main__":
sync()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。