Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Untuk input prodeskel dengan menggunakan Kantu Browser Automation. Script ini untuk men-generate file json
import csvimport csv
print("Harap tunggu, file sedang diproses")
file = open("testfilekutiga.json","w")
file.write("{")
file.write(" \"CreationDate\": \"2017-12-21\",")
file.write("\n")
file.write("\"Commands\": [")
file.write("\n")
x = 1
with open('datakependudukan.csv') as csvDataFile:
csvReader = csv.DictReader(csvDataFile, delimiter=';')
for row in csvReader:
if(x<=6):
if(row['shdk']=="KK"):
file.write(" {")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_kode_keluarga\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_kode_keluarga\",")
file.write("\n")
file.write("\"Value\": \""+str(row['nik'])+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_namakk\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_namakk\",")
file.write("\n")
file.write("\"Value\": \""+str(row['nama_lengkap'].replace(" ","<SP>"))+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_alamat\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_alamat\",")
file.write("\n")
file.write("\"Value\": \""+str(row['alamat'].replace(" ","<SP>"))+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rt\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rt\",")
file.write("\n")
file.write("\"Value\": \"%03d\"" % (int(row['rt'],)))
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rw\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rw\",")
file.write("\n")
file.write("\"Value\": \"%03d\"" % (int(row['rw'],)))
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_nama_dusun\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_nama_dusun\",")
file.write("\n")
file.write("\"Value\": \"BANGKA BELITUNG LAUT\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"JOKO SANTOSO\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=hidden_field_data_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d015\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d015\",")
file.write("\n")
file.write("\"Value\": \"PNS\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d016\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d016\",")
file.write("\n")
file.write("\"Value\": \"KASI PEMERINTAHAN UMUM\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d017\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d017\",")
file.write("\n")
file.write("\"Value\": \"KK\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"clickAndWait\",")
file.write("\n")
file.write("\"Target\": \"id=sc_b_ins_b\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
x = x+1
file.write("\n")
file.write("]")
file.write("\n")
file.write("}")
file.write("\n")
file.close()
print("File selesai diproses")
print("Harap tunggu, file sedang diproses")
file = open("testfilekutiga.json","w")
file.write("{")
file.write(" \"CreationDate\": \"2017-12-21\",")
file.write("\n")
file.write("\"Commands\": [")
file.write("\n")
x = 1
with open('datakependudukan.csv') as csvDataFile:
csvReader = csv.DictReader(csvDataFile, delimiter=';')
for row in csvReader:
if(x<=6):
if(row['shdk']=="KK"):
file.write(" {")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_kode_keluarga\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_kode_keluarga\",")
file.write("\n")
file.write("\"Value\": \""+str(row['nik'])+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_namakk\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_namakk\",")
file.write("\n")
file.write("\"Value\": \""+str(row['nama_lengkap'].replace(" ","<SP>"))+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_alamat\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_alamat\",")
file.write("\n")
file.write("\"Value\": \""+str(row['alamat'].replace(" ","<SP>"))+"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rt\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rt\",")
file.write("\n")
file.write("\"Value\": \"%03d\"" % (int(row['rt'],)))
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rw\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_rw\",")
file.write("\n")
file.write("\"Value\": \"%03d\"" % (int(row['rw'],)))
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_nama_dusun\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_nama_dusun\",")
file.write("\n")
file.write("\"Value\": \"BANGKA BELITUNG LAUT\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d014\",")
file.write("\n")
file.write("\"Value\": \"JOKO SANTOSO\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=hidden_field_data_d014\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d015\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d015\",")
file.write("\n")
file.write("\"Value\": \"PNS\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d016\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d016\",")
file.write("\n")
file.write("\"Value\": \"KASI PEMERINTAHAN UMUM\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"click\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d017\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"type\",")
file.write("\n")
file.write("\"Target\": \"id=id_sc_field_d017\",")
file.write("\n")
file.write("\"Value\": \"KK\"")
file.write("\n")
file.write("},")
file.write("\n")
file.write("{")
file.write("\n")
file.write("\"Command\": \"clickAndWait\",")
file.write("\n")
file.write("\"Target\": \"id=sc_b_ins_b\",")
file.write("\n")
file.write("\"Value\": \"\"")
file.write("\n")
file.write("},")
x = x+1
file.write("\n")
file.write("]")
file.write("\n")
file.write("}")
file.write("\n")
file.close()
print("File selesai diproses")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.