How to create read csv file data and upload that data to erpnext doctype

import csv
from frappeclient import FrappeClient

longitude = 2
latitude = 2
country = 2
total = 2

client = FrappeClient(“Frappe Cloud”, “6d04d4b78c7c810”)

def sync():
print(“logging in…”)
#client = FrappeClient(“Frappe Cloud”, “6d04d4b78c7c810”)
with open(“test.csv”, “rU”) as testfile:
reader = csv.reader(testfile, dialect=‘excel’)
for row in reader:
if row[0]==“Timestamp”:
continue

		print("finding " + row[country])
		name = client.get_value("check",{"name": row[country]})

		if name:
			doc = client.get_doc(name["name"])
		else:
			doc = {"doctype":"check"}

		doc["longitude"] = row[longitude]
		doc["latitude"] = row[latitude]
		doc["country"] = row[country]
		doc["total"] = row[total]

if name==“main”:
sync()