コード例 #1
0
ファイル: casexml.py プロジェクト: SEL-Columbia/casexml
    def export_csv(self):
        info = {}
        # Check if template exist before
        if not check_file(self.template, "xml"):
            print "Template doesnot exist, or invalid template. Check if " "it has a .xml extenion"
            return 0

        try:
            data = csv.reader(open(self.file_name, "rb"))
        except:
            print "Data doesnt exist"

        try:
            DOMAIN_URL = CONST.COMMCARE_URL
            SUBMIT_CASEXML = CONST.SUBMIT_TO_COMMCARE
        except:
            SUBMIT_CASEXML = False
            DOMAIN_URL = u""
        # Remove Header
        header = data.next()
        info = {}
        c = 1
        # Loop through each row and get data
        for x in data:
            for label, value in zip(header, x):
                info[label] = value.strip()
            print "Processing %d case: %s" % (c, info["hid"])
            form = CaseXMLInterface(info, self.template)
            save_casexmlform(form)
            if SUBMIT_CASEXML:
                transmit_form(form, DOMAIN_URL)
            c += 1
        print "Processed %d cases" % c
コード例 #2
0
ファイル: casexml.py プロジェクト: mvpdev/casexml
    def export_csv(self):
        info = {}
        #Check if template exist before
        if not check_file(self.template, "xml"):
            print "Template doesnot exist, or invalid template. Check if " \
                    "it has a .xml extenion"
            return 0

        try:
            data = csv.reader(open(self.file_name, 'rb'))
        except:
            print "Data doesnt exist"

        #Remove Header
        header = data.next()
        info = {}
        #Loop through each row and get data
        for x in data:
            for label, value in zip(header, x):
                info[label] = value

            form = CaseXMLInterface(info, self.template)
            save_casexmlform(form)