Exemplo n.º 1
0
		distribution = {}
		for value in values:
			if distribution.has_key (value):
				distribution [value] += 1
			else:
				distribution [value] = 1
		cd = classifiedunicodevalue.ClassifiedDistribution (distribution)
		if cd.dataType == "integer":
			jsonType = "integer"
		elif cd.dataType == "decimal":
			jsonType = "decimal"
		elif cd.dataType == "text":
			jsonType = "string"
		else:
			jsonType = "null"		
		variables [variableName] = {
			"sequence": index + 1,
			"name": variableName,
			"json_type": jsonType,
			"distribution": cd.toObject (includeTotal=False)
		}
		data [variableName] = compressedValues (values, jsonType)

	jsonFile = open (outputFilename, 'wb')
	json.dump (jsonObject, jsonFile,
		sort_keys=True,
		indent=4,
		separators=(',', ': ')
	)
	jsonFile.close ()
Exemplo n.º 2
0
        distribution = {}
        for value in values:
            if distribution.has_key(value):
                distribution[value] += 1
            else:
                distribution[value] = 1
        cd = classifiedunicodevalue.ClassifiedDistribution(distribution)
        if cd.dataType == "integer":
            jsonType = "integer"
        elif cd.dataType == "decimal":
            jsonType = "decimal"
        elif cd.dataType == "text":
            jsonType = "string"
        else:
            jsonType = "null"
        variables[variableName] = {
            "sequence": index + 1,
            "name": variableName,
            "json_type": jsonType,
            "distribution": cd.toObject(includeTotal=False)
        }
        data[variableName] = compressedValues(values, jsonType)

    jsonFile = open(outputFilename, 'wb')
    json.dump(jsonObject,
              jsonFile,
              sort_keys=True,
              indent=4,
              separators=(',', ': '))
    jsonFile.close()