Skip to content

Instantly share code, notes, and snippets.

@bkiu
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkiu/b3a835cbfd0cc41838fa to your computer and use it in GitHub Desktop.
Save bkiu/b3a835cbfd0cc41838fa to your computer and use it in GitHub Desktop.
import frappe
import cProfile
DATA_FILE = "data/MYDATA.txt"
DELIM = "|"
data_cols = {
"0": "first_name",
"1": "last_name",
"2": "gender",
"3": "date_of_birth"
}
frappe.init("my_site", "/home/linuxuser/frappe-bench/sites")
for line in open(DATA_FILE):
if line.find("STCODE|") >= 0:
continue
parts = line.split(DELIM)
entry = frappe.new_doc("My DocType")
for index in data_cols:
field = data_cols[index]
index = int(index)
entry.set(field, parts[index])
print("Field with id=%s added." % parts[0])
frappe.db.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment