Last active
August 29, 2015 14:05
-
-
Save bkiu/b3a835cbfd0cc41838fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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