1 Star 0 Fork 0

cn-frappe/frappe-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
example.py 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
mohammadahmad1990 提交于 2020-05-31 16:33 . python 2 and 3 compatibility
# 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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cn-frappe/frappe-client.git
git@gitee.com:cn-frappe/frappe-client.git
cn-frappe
frappe-client
frappe-client
master

搜索帮助