-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathimport_symptoms.py
48 lines (33 loc) · 1.03 KB
/
import_symptoms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import frappe
from openpyxl import load_workbook
def import_data():
# Load the workbook
wb = load_workbook("symptoms.xlsx")
# Get the sheet
sheet = wb.active
# Max row
max_row = sheet.max_row
print "Importing the Data."
# The index starts at 1
for row in range(2, max_row + 1):
# Symptom Name
c1 = sheet.cell(row=row, column=1)
# Description
c2 = sheet.cell(row=row, column=2)
# Causes
c3 = sheet.cell(row=row, column=3)
# When to See a Doctor
c4 = sheet.cell(row=row, column=4)
# Category
c5 = sheet.cell(row=row, column=5)
# Symptom's Description and Causes
doc = frappe.get_doc({
"doctype": "Symptoms Description and Causes",
"symptom_name": c1.value,
"description": c2.value,
"causes": c3.value,
"when": c4.value,
"category": c5.value
})
doc.insert()
print "Imported data {0}/{1}".format(row - 1, max_row - 1)