diff --git a/database_creation/test/total_type.py b/database_creation/test/total_type.py index 11fd8817..00c51387 100644 --- a/database_creation/test/total_type.py +++ b/database_creation/test/total_type.py @@ -19,29 +19,48 @@ def test(cursor): nb_reporting_annual_flows, total_flows=cursor.fetchone() print "%s number of reporting exp or imp total annual flows on %s total"%(nb_reporting_annual_flows,total_flows) - cursor.execute("""SELECT world_type_group, sum(nb) as sum FROM (SELECT count(*) as nb,group_concat(partner,"|") as world_type_group + + print "\nrepartition of type of Total Trade to World as duplicates:" + + cursor.execute("""SELECT count(*) FROM (SELECT count(*) as nb,group_concat(partner,"|") as world_type_group FROM flow_joined - WHERE partner IN ("World_undefined","World_estimated","World_as_reported","World_as_reported2") + WHERE partner IN ("World_estimated","World_as_reported") group by reporting,Yr,expimp ) + """) + compatible_world_flows_worldview=cursor.fetchone()[0] + print "\n%s %.1f%% flows compatible with world view"%(compatible_world_flows_worldview,100*float(compatible_world_flows_worldview)/nb_reporting_annual_flows) + + cursor.execute("""SELECT count(*) FROM (SELECT count(*) as nb,group_concat(partner,"|") as world_type_group + FROM flow_joined + WHERE partner IN ("World_as_reported","World_as_reported2") + group by reporting,Yr,expimp ) + """) + compatible_world_flows_countryview=cursor.fetchone()[0] + print "%s %.1f%% flows compatible with world view"%(compatible_world_flows_countryview,100*float(compatible_world_flows_countryview)/nb_reporting_annual_flows) + + cursor.execute("""SELECT count(*) FROM (SELECT count(*) as nb,group_concat(partner,"|") as world_type_group + FROM flow_joined + + group by reporting,Yr,expimp ) + WHERE world_type_group="World_undefined" group by world_type_group - ORDER BY sum DESC """) - print "\nrepartition of type of Total Trade to World as duplicates:" - missing_world_flows_worldview=0 - missing_world_flows_countryview=0 - undefined=0 + undefined=cursor.fetchone()[0] + print "%s flows to World with only undefined Total"%(undefined) + # missing_world_flows_countryview=0 + # undefined=0 - for world_type_group,nb in cursor: - print world_type_group,nb - if "World_estimated" in world_type_group or "World_as_reported" in world_type_group: - missing_world_flows_worldview+=nb - if "World_as_reported2" in world_type_group or "World_as_reported" in world_type_group: - missing_world_flows_countryview+=nb - if world_type_group == "World_undefined": - undefined+=nb - print "\n%s %.1f%% flows compatible with world view"%(missing_world_flows_worldview,100*float(missing_world_flows_worldview)/nb_reporting_annual_flows) - print "%s %.1f%% flows compatible with country view"%(missing_world_flows_countryview,100*float(missing_world_flows_countryview)/nb_reporting_annual_flows) - print "%s Total trade to World flows with no type"%undefined + # for world_type_group,nb in cursor: + # print world_type_group,nb + # if "World_estimated" in world_type_group or "World_as_reported" in world_type_group: + # missing_world_flows_worldview+=nb + # if "World_as_reported2" in world_type_group or "World_as_reported" in world_type_group: + # missing_world_flows_countryview+=nb + # if world_type_group == "World_undefined": + # undefined+=nb + # print "\n%s %.1f%% flows compatible with world view"%(missing_world_flows_worldview,100*float(missing_world_flows_worldview)/nb_reporting_annual_flows) + # print "%s %.1f%% flows compatible with country view"%(missing_world_flows_countryview,100*float(missing_world_flows_countryview)/nb_reporting_annual_flows) + # print "%s Total trade to World flows with no type"%undefined print "\nisolating World_undefined-only flows :"