From 3175d648060e9f0c3c0f966a88c0fd86db43cc4b Mon Sep 17 00:00:00 2001 From: Guglielmo Date: Wed, 10 Jun 2015 16:03:18 +0100 Subject: [PATCH] Add Italian management scripts. --- mapit_it/cap.csv | 4481 +++++++++++++++++ mapit_it/circoscrizioni.csv | 32 + .../mapit_IT_generate_constituencies_csv.py | 171 + .../commands/mapit_IT_import_postal_codes.py | 63 + 4 files changed, 4747 insertions(+) create mode 100644 mapit_it/cap.csv create mode 100644 mapit_it/circoscrizioni.csv create mode 100644 mapit_it/management/commands/mapit_IT_generate_constituencies_csv.py create mode 100644 mapit_it/management/commands/mapit_IT_import_postal_codes.py diff --git a/mapit_it/cap.csv b/mapit_it/cap.csv new file mode 100644 index 00000000..c1e5b1d6 --- /dev/null +++ b/mapit_it/cap.csv @@ -0,0 +1,4481 @@ +00010 +00011 +00012 +00013 +00015 +00017 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00065 +00066 +00067 +00068 +00069 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00181 +00182 +00183 +00184 +00185 +00186 +00187 +00188 +00189 +00191 +00192 +00193 +00194 +00195 +00196 +00197 +00198 +00199 +01010 +01011 +01012 +01014 +01015 +01016 +01017 +01018 +01019 +01020 +01021 +01022 +01023 +01024 +01025 +01026 +01027 +01028 +01030 +01032 +01033 +01034 +01035 +01036 +01037 +01038 +01039 +01100 +02010 +02011 +02012 +02013 +02014 +02015 +02016 +02018 +02019 +02020 +02021 +02022 +02023 +02024 +02025 +02026 +02028 +02030 +02031 +02032 +02033 +02034 +02035 +02037 +02038 +02039 +02040 +02041 +02042 +02043 +02044 +02045 +02046 +02047 +02048 +02049 +02100 +03010 +03011 +03012 +03013 +03014 +03016 +03017 +03018 +03019 +03020 +03021 +03022 +03023 +03024 +03025 +03026 +03027 +03028 +03029 +03030 +03031 +03032 +03033 +03034 +03035 +03036 +03037 +03038 +03039 +03040 +03041 +03042 +03043 +03044 +03045 +03046 +03047 +03048 +03049 +03100 +04010 +04011 +04012 +04013 +04014 +04015 +04016 +04017 +04018 +04019 +04020 +04021 +04022 +04023 +04024 +04025 +04026 +04027 +04028 +04029 +04100 +05010 +05011 +05012 +05013 +05014 +05015 +05016 +05017 +05018 +05020 +05021 +05022 +05023 +05024 +05025 +05026 +05028 +05029 +05030 +05031 +05032 +05034 +05035 +05039 +05100 +06010 +06012 +06014 +06016 +06018 +06019 +06020 +06021 +06022 +06023 +06024 +06025 +06026 +06027 +06028 +06029 +06030 +06031 +06033 +06034 +06035 +06036 +06038 +06039 +06040 +06041 +06042 +06043 +06044 +06045 +06046 +06047 +06049 +06050 +06051 +06053 +06054 +06055 +06056 +06057 +06059 +06060 +06061 +06062 +06063 +06064 +06065 +06066 +06068 +06069 +06070 +06072 +06073 +06081 +06083 +06084 +06089 +06121 +06122 +06123 +06124 +06125 +06126 +06127 +06128 +06129 +06131 +06132 +06133 +06134 +06135 +07010 +07011 +07012 +07013 +07014 +07015 +07016 +07017 +07018 +07019 +07020 +07021 +07022 +07023 +07024 +07025 +07026 +07027 +07028 +07029 +07030 +07031 +07032 +07033 +07034 +07035 +07036 +07037 +07038 +07039 +07040 +07041 +07043 +07044 +07045 +07046 +07047 +07048 +07049 +07100 +08010 +08011 +08012 +08013 +08015 +08016 +08017 +08018 +08019 +08020 +08021 +08022 +08023 +08024 +08025 +08026 +08027 +08028 +08029 +08030 +08031 +08032 +08033 +08034 +08035 +08036 +08037 +08038 +08039 +08040 +08042 +08043 +08044 +08045 +08046 +08047 +08048 +08049 +08100 +09010 +09011 +09012 +09013 +09014 +09015 +09016 +09017 +09018 +09019 +09020 +09021 +09022 +09023 +09024 +09025 +09026 +09027 +09028 +09029 +09030 +09031 +09032 +09033 +09034 +09035 +09036 +09037 +09038 +09039 +09040 +09041 +09042 +09043 +09044 +09045 +09047 +09048 +09049 +09070 +09071 +09072 +09073 +09074 +09075 +09076 +09077 +09078 +09079 +09080 +09081 +09082 +09083 +09084 +09085 +09086 +09088 +09090 +09091 +09092 +09093 +09094 +09095 +09096 +09097 +09098 +09099 +09121 +09122 +09123 +09124 +09125 +09126 +09127 +09128 +09129 +09131 +09134 +09170 +10010 +10011 +10012 +10013 +10014 +10015 +10016 +10017 +10018 +10019 +10020 +10022 +10023 +10024 +10025 +10026 +10028 +10029 +10030 +10031 +10032 +10034 +10035 +10036 +10037 +10038 +10040 +10041 +10042 +10043 +10044 +10045 +10046 +10048 +10050 +10051 +10052 +10053 +10054 +10055 +10056 +10057 +10058 +10059 +10060 +10061 +10062 +10063 +10064 +10065 +10066 +10067 +10068 +10069 +10070 +10071 +10072 +10073 +10074 +10075 +10076 +10077 +10078 +10080 +10081 +10082 +10083 +10084 +10085 +10086 +10087 +10088 +10090 +10091 +10092 +10093 +10094 +10095 +10098 +10099 +10121 +10122 +10123 +10124 +10125 +10126 +10127 +10128 +10129 +10131 +10132 +10133 +10134 +10135 +10136 +10137 +10138 +10139 +10141 +10142 +10143 +10144 +10145 +10146 +10147 +10148 +10149 +10151 +10152 +10153 +10154 +10155 +10156 +11010 +11011 +11012 +11013 +11014 +11015 +11016 +11017 +11018 +11020 +11021 +11022 +11023 +11024 +11025 +11026 +11027 +11028 +11029 +11100 +12010 +12011 +12012 +12013 +12014 +12015 +12016 +12017 +12018 +12019 +12020 +12021 +12022 +12023 +12024 +12025 +12026 +12027 +12028 +12029 +12030 +12031 +12032 +12033 +12034 +12035 +12036 +12037 +12038 +12039 +12040 +12041 +12042 +12043 +12044 +12045 +12046 +12047 +12048 +12049 +12050 +12051 +12052 +12053 +12054 +12055 +12056 +12058 +12060 +12061 +12062 +12063 +12064 +12065 +12066 +12068 +12069 +12070 +12071 +12072 +12073 +12074 +12075 +12076 +12077 +12078 +12079 +12080 +12081 +12082 +12083 +12084 +12087 +12088 +12089 +12100 +13010 +13011 +13012 +13017 +13018 +13019 +13020 +13021 +13022 +13023 +13024 +13025 +13026 +13027 +13028 +13030 +13031 +13032 +13033 +13034 +13035 +13036 +13037 +13038 +13039 +13040 +13041 +13043 +13044 +13045 +13046 +13047 +13048 +13049 +13060 +13100 +13811 +13812 +13814 +13815 +13816 +13817 +13818 +13821 +13822 +13823 +13824 +13825 +13831 +13833 +13834 +13835 +13836 +13841 +13843 +13844 +13845 +13847 +13848 +13851 +13852 +13853 +13854 +13855 +13856 +13861 +13862 +13863 +13864 +13865 +13866 +13867 +13868 +13871 +13872 +13873 +13874 +13875 +13876 +13877 +13878 +13881 +13882 +13883 +13884 +13885 +13886 +13887 +13888 +13891 +13893 +13894 +13895 +13896 +13897 +13898 +13899 +13900 +14010 +14011 +14012 +14013 +14014 +14015 +14016 +14017 +14018 +14019 +14020 +14021 +14022 +14023 +14024 +14025 +14026 +14030 +14031 +14032 +14033 +14034 +14035 +14036 +14037 +14039 +14040 +14041 +14042 +14043 +14044 +14045 +14046 +14047 +14048 +14049 +14050 +14051 +14052 +14053 +14054 +14055 +14057 +14058 +14059 +14100 +15010 +15011 +15012 +15013 +15014 +15015 +15016 +15017 +15018 +15019 +15020 +15021 +15022 +15023 +15024 +15025 +15026 +15027 +15028 +15029 +15030 +15031 +15032 +15033 +15034 +15035 +15036 +15038 +15039 +15040 +15041 +15042 +15043 +15044 +15045 +15046 +15048 +15049 +15050 +15051 +15052 +15053 +15054 +15055 +15056 +15057 +15058 +15059 +15060 +15061 +15062 +15063 +15064 +15065 +15066 +15067 +15068 +15069 +15070 +15071 +15072 +15073 +15074 +15075 +15076 +15077 +15078 +15079 +15100 +16010 +16011 +16012 +16013 +16014 +16015 +16016 +16017 +16018 +16019 +16020 +16021 +16022 +16023 +16024 +16025 +16026 +16027 +16028 +16029 +16030 +16031 +16032 +16033 +16034 +16035 +16036 +16038 +16039 +16040 +16041 +16042 +16043 +16044 +16045 +16046 +16047 +16048 +16049 +16121 +16122 +16123 +16124 +16125 +16126 +16127 +16128 +16129 +16131 +16132 +16133 +16134 +16135 +16136 +16137 +16138 +16139 +16141 +16142 +16143 +16144 +16145 +16146 +16147 +16148 +16149 +16151 +16152 +16153 +16154 +16155 +16156 +16157 +16158 +16159 +16161 +16162 +16163 +16164 +16165 +16166 +16167 +17010 +17011 +17012 +17013 +17014 +17015 +17017 +17019 +17020 +17021 +17022 +17023 +17024 +17025 +17026 +17027 +17028 +17030 +17031 +17032 +17033 +17034 +17035 +17037 +17038 +17039 +17040 +17041 +17042 +17043 +17044 +17045 +17046 +17047 +17048 +17051 +17052 +17053 +17054 +17055 +17056 +17057 +17058 +17100 +18010 +18011 +18012 +18013 +18014 +18015 +18016 +18017 +18018 +18019 +18020 +18021 +18022 +18023 +18024 +18025 +18026 +18027 +18030 +18031 +18032 +18033 +18034 +18035 +18036 +18037 +18038 +18039 +18100 +19010 +19011 +19012 +19013 +19014 +19015 +19016 +19017 +19018 +19020 +19021 +19025 +19028 +19030 +19031 +19032 +19033 +19034 +19037 +19038 +20010 +20011 +20012 +20013 +20014 +20015 +20016 +20017 +20018 +20019 +20020 +20021 +20022 +20023 +20024 +20025 +20026 +20027 +20028 +20029 +20030 +20031 +20032 +20033 +20034 +20035 +20036 +20037 +20038 +20039 +20040 +20041 +20042 +20043 +20044 +20045 +20046 +20047 +20048 +20049 +20050 +20051 +20052 +20053 +20054 +20055 +20056 +20057 +20058 +20059 +20060 +20061 +20062 +20063 +20064 +20065 +20066 +20067 +20068 +20069 +20070 +20077 +20078 +20080 +20081 +20082 +20083 +20084 +20085 +20086 +20087 +20088 +20089 +20090 +20091 +20092 +20093 +20094 +20095 +20096 +20097 +20098 +20099 +20121 +20122 +20123 +20124 +20125 +20126 +20127 +20128 +20129 +20131 +20132 +20133 +20134 +20135 +20136 +20137 +20138 +20139 +20141 +20142 +20143 +20144 +20145 +20146 +20147 +20148 +20149 +20151 +20152 +20153 +20154 +20155 +20156 +20157 +20158 +20159 +20161 +20162 +21010 +21011 +21012 +21013 +21014 +21015 +21016 +21017 +21018 +21019 +21020 +21021 +21022 +21023 +21024 +21025 +21026 +21027 +21028 +21029 +21030 +21031 +21032 +21033 +21034 +21035 +21036 +21037 +21038 +21039 +21040 +21041 +21042 +21043 +21044 +21045 +21046 +21047 +21048 +21049 +21050 +21051 +21052 +21053 +21054 +21055 +21056 +21057 +21058 +21059 +21100 +22010 +22011 +22012 +22013 +22014 +22015 +22016 +22017 +22018 +22019 +22020 +22021 +22022 +22023 +22024 +22025 +22026 +22027 +22028 +22029 +22030 +22031 +22032 +22033 +22034 +22035 +22036 +22037 +22038 +22039 +22040 +22044 +22045 +22046 +22060 +22063 +22066 +22069 +22070 +22071 +22072 +22073 +22074 +22075 +22076 +22077 +22078 +22079 +22100 +23010 +23011 +23012 +23013 +23014 +23015 +23016 +23017 +23018 +23019 +23020 +23021 +23022 +23023 +23024 +23025 +23026 +23027 +23029 +23030 +23031 +23032 +23033 +23034 +23035 +23036 +23037 +23038 +23100 +23801 +23802 +23804 +23805 +23806 +23807 +23808 +23811 +23813 +23814 +23815 +23816 +23817 +23818 +23819 +23821 +23822 +23823 +23824 +23825 +23826 +23827 +23828 +23829 +23831 +23832 +23833 +23834 +23835 +23836 +23837 +23838 +23841 +23842 +23843 +23844 +23845 +23846 +23847 +23848 +23849 +23851 +23852 +23854 +23855 +23857 +23861 +23862 +23864 +23865 +23867 +23868 +23870 +23871 +23873 +23874 +23875 +23876 +23877 +23878 +23879 +23880 +23881 +23883 +23884 +23885 +23886 +23887 +23888 +23889 +23890 +23891 +23892 +23893 +23894 +23895 +23896 +23897 +23898 +23899 +23900 +24010 +24011 +24012 +24013 +24014 +24015 +24016 +24017 +24018 +24019 +24020 +24021 +24022 +24023 +24024 +24025 +24026 +24027 +24028 +24029 +24030 +24031 +24033 +24034 +24035 +24036 +24037 +24038 +24039 +24040 +24041 +24042 +24043 +24044 +24045 +24046 +24047 +24048 +24049 +24050 +24051 +24052 +24053 +24054 +24055 +24056 +24057 +24058 +24059 +24060 +24061 +24062 +24063 +24064 +24065 +24066 +24067 +24068 +24069 +24121 +24122 +24123 +24124 +24125 +24126 +24127 +24128 +24129 +25010 +25011 +25012 +25013 +25014 +25015 +25016 +25017 +25018 +25019 +25020 +25021 +25022 +25023 +25024 +25025 +25026 +25027 +25028 +25029 +25030 +25031 +25032 +25033 +25034 +25035 +25036 +25037 +25038 +25039 +25040 +25041 +25042 +25043 +25044 +25045 +25046 +25047 +25048 +25049 +25050 +25051 +25052 +25053 +25054 +25055 +25056 +25057 +25058 +25059 +25060 +25061 +25062 +25063 +25064 +25065 +25068 +25069 +25070 +25071 +25072 +25073 +25074 +25075 +25076 +25077 +25078 +25079 +25080 +25081 +25082 +25083 +25084 +25085 +25086 +25087 +25088 +25089 +25121 +25122 +25123 +25124 +25125 +25126 +25127 +25128 +25129 +25131 +25132 +25133 +25134 +25135 +25136 +26010 +26011 +26012 +26013 +26014 +26015 +26016 +26017 +26018 +26019 +26020 +26021 +26022 +26023 +26024 +26025 +26026 +26027 +26028 +26029 +26030 +26031 +26032 +26033 +26034 +26035 +26036 +26037 +26038 +26039 +26040 +26041 +26042 +26043 +26044 +26045 +26046 +26047 +26048 +26049 +26100 +26811 +26812 +26813 +26814 +26815 +26816 +26817 +26818 +26821 +26822 +26823 +26824 +26825 +26826 +26827 +26828 +26831 +26832 +26833 +26834 +26835 +26836 +26837 +26838 +26839 +26841 +26842 +26843 +26844 +26845 +26846 +26847 +26848 +26849 +26851 +26852 +26853 +26854 +26855 +26856 +26857 +26858 +26859 +26861 +26862 +26863 +26864 +26865 +26866 +26867 +26900 +27010 +27011 +27012 +27013 +27014 +27015 +27016 +27017 +27018 +27019 +27020 +27021 +27022 +27023 +27024 +27025 +27026 +27027 +27028 +27029 +27030 +27031 +27032 +27033 +27034 +27035 +27036 +27037 +27038 +27039 +27040 +27041 +27042 +27043 +27044 +27045 +27046 +27047 +27048 +27049 +27050 +27051 +27052 +27053 +27054 +27055 +27057 +27058 +27059 +27100 +28010 +28011 +28012 +28013 +28014 +28015 +28016 +28017 +28019 +28021 +28024 +28028 +28040 +28041 +28043 +28045 +28046 +28047 +28050 +28053 +28060 +28061 +28062 +28064 +28065 +28066 +28068 +28069 +28070 +28071 +28072 +28073 +28074 +28075 +28076 +28077 +28078 +28079 +28100 +28801 +28802 +28803 +28804 +28805 +28811 +28812 +28813 +28814 +28815 +28816 +28817 +28818 +28819 +28821 +28822 +28823 +28824 +28825 +28826 +28827 +28828 +28831 +28832 +28833 +28836 +28838 +28841 +28842 +28843 +28844 +28845 +28851 +28852 +28853 +28854 +28855 +28856 +28857 +28858 +28859 +28861 +28862 +28863 +28864 +28865 +28866 +28868 +28871 +28873 +28875 +28876 +28877 +28879 +28881 +28883 +28884 +28885 +28886 +28887 +28891 +28893 +28894 +28895 +28896 +28897 +28898 +28899 +28921 +28922 +28923 +28924 +28925 +29010 +29011 +29012 +29013 +29014 +29015 +29016 +29017 +29018 +29019 +29020 +29021 +29022 +29023 +29024 +29025 +29026 +29027 +29028 +29029 +29100 +30010 +30013 +30014 +30015 +30016 +30020 +30021 +30022 +30023 +30024 +30025 +30026 +30027 +30028 +30029 +30030 +30031 +30032 +30033 +30034 +30035 +30036 +30037 +30038 +30039 +30121 +30122 +30123 +30124 +30125 +30126 +30132 +30133 +30135 +30141 +30142 +30171 +30172 +30173 +30174 +30175 +30176 +31010 +31011 +31012 +31013 +31014 +31015 +31016 +31017 +31018 +31020 +31021 +31022 +31023 +31024 +31025 +31026 +31027 +31028 +31029 +31030 +31031 +31032 +31033 +31034 +31035 +31036 +31037 +31038 +31039 +31040 +31041 +31042 +31043 +31044 +31045 +31046 +31047 +31048 +31049 +31050 +31051 +31052 +31053 +31054 +31055 +31056 +31057 +31058 +31059 +31100 +32010 +32012 +32013 +32014 +32015 +32016 +32020 +32021 +32022 +32026 +32027 +32028 +32030 +32031 +32032 +32033 +32034 +32035 +32036 +32037 +32040 +32041 +32042 +32043 +32044 +32045 +32046 +32047 +32100 +33010 +33011 +33013 +33015 +33016 +33017 +33018 +33019 +33020 +33021 +33022 +33023 +33024 +33025 +33026 +33027 +33028 +33029 +33030 +33031 +33032 +33033 +33034 +33035 +33036 +33037 +33038 +33039 +33040 +33041 +33042 +33043 +33044 +33045 +33046 +33047 +33048 +33049 +33050 +33051 +33052 +33053 +33054 +33055 +33056 +33057 +33058 +33059 +33070 +33072 +33074 +33075 +33076 +33077 +33078 +33079 +33080 +33081 +33082 +33083 +33084 +33085 +33086 +33087 +33090 +33092 +33094 +33095 +33097 +33098 +33099 +33100 +33170 +34010 +34011 +34012 +34014 +34015 +34016 +34017 +34018 +34070 +34071 +34072 +34073 +34074 +34075 +34076 +34077 +34078 +34079 +34121 +34122 +34123 +34124 +34125 +34126 +34127 +34128 +34129 +34131 +34132 +34133 +34134 +34135 +34136 +34137 +34138 +34139 +34141 +34142 +34143 +34144 +34145 +34146 +34147 +34148 +34149 +34151 +34170 +35010 +35011 +35012 +35013 +35014 +35015 +35016 +35017 +35018 +35019 +35020 +35021 +35022 +35023 +35024 +35025 +35026 +35027 +35028 +35029 +35030 +35031 +35032 +35034 +35035 +35036 +35037 +35038 +35040 +35041 +35042 +35043 +35044 +35045 +35046 +35047 +35048 +35121 +35122 +35123 +35124 +35125 +35126 +35127 +35128 +35129 +35131 +35132 +35133 +35134 +35135 +35136 +35137 +35138 +35139 +35141 +35142 +35143 +36010 +36011 +36012 +36013 +36014 +36015 +36016 +36020 +36021 +36022 +36023 +36024 +36025 +36026 +36027 +36028 +36030 +36031 +36032 +36033 +36034 +36035 +36036 +36040 +36042 +36043 +36045 +36046 +36047 +36050 +36051 +36052 +36053 +36054 +36055 +36056 +36057 +36060 +36061 +36062 +36063 +36064 +36065 +36066 +36070 +36071 +36072 +36073 +36075 +36076 +36077 +36078 +36100 +37010 +37011 +37012 +37013 +37014 +37015 +37016 +37017 +37018 +37019 +37020 +37021 +37022 +37023 +37024 +37026 +37028 +37029 +37030 +37031 +37032 +37035 +37036 +37038 +37039 +37040 +37041 +37042 +37043 +37044 +37045 +37046 +37047 +37049 +37050 +37051 +37052 +37053 +37054 +37055 +37056 +37057 +37058 +37059 +37060 +37062 +37063 +37064 +37066 +37067 +37068 +37069 +37121 +37122 +37123 +37124 +37125 +37126 +37127 +37128 +37129 +37131 +37132 +37133 +37134 +37135 +37136 +37137 +37138 +37139 +37141 +37142 +38010 +38011 +38012 +38013 +38015 +38016 +38017 +38018 +38019 +38020 +38021 +38022 +38023 +38024 +38025 +38026 +38027 +38028 +38029 +38030 +38031 +38032 +38033 +38034 +38035 +38036 +38037 +38038 +38039 +38040 +38041 +38042 +38043 +38045 +38046 +38047 +38048 +38049 +38050 +38051 +38052 +38053 +38054 +38055 +38056 +38057 +38059 +38060 +38061 +38062 +38063 +38064 +38065 +38066 +38068 +38069 +38070 +38071 +38072 +38073 +38074 +38075 +38076 +38078 +38079 +38080 +38081 +38082 +38083 +38085 +38086 +38087 +38088 +38089 +38100 +39010 +39011 +39012 +39013 +39014 +39015 +39016 +39017 +39018 +39019 +39020 +39021 +39022 +39023 +39024 +39025 +39026 +39027 +39028 +39029 +39030 +39031 +39032 +39033 +39034 +39035 +39036 +39037 +39038 +39039 +39040 +39041 +39042 +39043 +39044 +39045 +39046 +39047 +39048 +39049 +39050 +39051 +39052 +39053 +39054 +39055 +39056 +39057 +39058 +39100 +40010 +40011 +40012 +40013 +40014 +40015 +40016 +40017 +40018 +40019 +40020 +40021 +40022 +40023 +40024 +40025 +40026 +40027 +40030 +40032 +40033 +40034 +40035 +40036 +40037 +40038 +40041 +40042 +40043 +40045 +40046 +40048 +40050 +40051 +40052 +40053 +40054 +40055 +40056 +40057 +40059 +40060 +40061 +40062 +40063 +40064 +40065 +40066 +40067 +40068 +40069 +40121 +40122 +40123 +40124 +40125 +40126 +40127 +40128 +40129 +40131 +40132 +40133 +40134 +40135 +40136 +40137 +40138 +40139 +40141 +41010 +41011 +41012 +41013 +41014 +41015 +41016 +41017 +41018 +41019 +41020 +41021 +41022 +41023 +41025 +41026 +41027 +41028 +41029 +41030 +41031 +41032 +41033 +41034 +41035 +41036 +41037 +41038 +41039 +41040 +41042 +41043 +41044 +41045 +41046 +41048 +41049 +41051 +41052 +41053 +41054 +41055 +41056 +41057 +41058 +41059 +41100 +42010 +42011 +42012 +42013 +42014 +42015 +42016 +42017 +42018 +42019 +42020 +42021 +42022 +42023 +42024 +42025 +42026 +42027 +42028 +42030 +42031 +42032 +42033 +42034 +42035 +42037 +42039 +42040 +42041 +42042 +42043 +42044 +42045 +42046 +42047 +42048 +42049 +42100 +43010 +43011 +43012 +43013 +43014 +43015 +43017 +43018 +43019 +43020 +43021 +43022 +43024 +43025 +43028 +43029 +43030 +43032 +43035 +43036 +43037 +43038 +43039 +43040 +43041 +43042 +43043 +43044 +43045 +43047 +43048 +43049 +43050 +43051 +43052 +43053 +43055 +43056 +43058 +43059 +43100 +44010 +44011 +44012 +44014 +44015 +44016 +44019 +44020 +44021 +44022 +44023 +44025 +44026 +44027 +44028 +44029 +44030 +44033 +44034 +44035 +44037 +44039 +44041 +44042 +44043 +44045 +44047 +44048 +44049 +44100 +45010 +45011 +45012 +45014 +45015 +45017 +45018 +45019 +45020 +45021 +45022 +45023 +45024 +45025 +45026 +45027 +45030 +45031 +45032 +45033 +45034 +45035 +45036 +45037 +45038 +45039 +45100 +46010 +46011 +46012 +46013 +46014 +46017 +46018 +46019 +46020 +46022 +46023 +46024 +46025 +46026 +46027 +46028 +46029 +46030 +46031 +46032 +46033 +46035 +46036 +46037 +46039 +46040 +46041 +46042 +46043 +46044 +46045 +46046 +46047 +46048 +46049 +46100 +47010 +47011 +47012 +47013 +47014 +47015 +47016 +47017 +47018 +47019 +47020 +47021 +47023 +47025 +47027 +47028 +47030 +47032 +47034 +47035 +47039 +47042 +47043 +47100 +47814 +47822 +47824 +47825 +47826 +47832 +47833 +47834 +47835 +47836 +47837 +47838 +47841 +47842 +47843 +47853 +47854 +47855 +47890 +47891 +47892 +47893 +47894 +47895 +47896 +47897 +47898 +47899 +47900 +48010 +48011 +48012 +48013 +48014 +48015 +48017 +48018 +48020 +48022 +48024 +48025 +48026 +48027 +48100 +50010 +50012 +50013 +50014 +50018 +50019 +50020 +50021 +50022 +50023 +50025 +50026 +50027 +50028 +50031 +50032 +50033 +50034 +50035 +50036 +50037 +50038 +50039 +50041 +50050 +50051 +50052 +50053 +50054 +50055 +50056 +50058 +50059 +50060 +50061 +50062 +50063 +50064 +50065 +50066 +50067 +50068 +50121 +50122 +50123 +50124 +50125 +50126 +50127 +50129 +50131 +50132 +50133 +50134 +50135 +50136 +50137 +50139 +50141 +50142 +50143 +50144 +50145 +51010 +51011 +51012 +51013 +51015 +51016 +51017 +51018 +51019 +51020 +51021 +51024 +51028 +51030 +51031 +51034 +51035 +51036 +51037 +51039 +51100 +52010 +52011 +52014 +52015 +52016 +52017 +52018 +52020 +52021 +52022 +52024 +52025 +52026 +52027 +52028 +52029 +52030 +52031 +52032 +52033 +52035 +52036 +52037 +52038 +52041 +52043 +52044 +52045 +52046 +52047 +52048 +52100 +53011 +53012 +53013 +53014 +53015 +53016 +53017 +53018 +53019 +53020 +53021 +53022 +53023 +53024 +53025 +53026 +53027 +53030 +53031 +53034 +53035 +53036 +53037 +53040 +53041 +53042 +53043 +53045 +53047 +53048 +53049 +53100 +54010 +54011 +54012 +54013 +54014 +54015 +54016 +54021 +54023 +54026 +54027 +54028 +54029 +54033 +54035 +54038 +54100 +55010 +55011 +55012 +55013 +55014 +55015 +55016 +55018 +55019 +55020 +55022 +55023 +55025 +55027 +55030 +55031 +55032 +55033 +55034 +55035 +55036 +55038 +55040 +55041 +55042 +55045 +55047 +55049 +55051 +55054 +55060 +55061 +55062 +55064 +55100 +56010 +56011 +56012 +56017 +56019 +56020 +56021 +56022 +56023 +56024 +56025 +56028 +56029 +56030 +56031 +56032 +56033 +56034 +56035 +56036 +56037 +56038 +56040 +56041 +56043 +56044 +56045 +56046 +56048 +56121 +56122 +56123 +56124 +56125 +56126 +56127 +56128 +57014 +57016 +57017 +57020 +57021 +57022 +57023 +57025 +57027 +57028 +57030 +57031 +57032 +57033 +57034 +57036 +57037 +57038 +57039 +57121 +57122 +57123 +57124 +57125 +57126 +57127 +57128 +58010 +58011 +58012 +58014 +58015 +58017 +58018 +58019 +58020 +58022 +58023 +58024 +58025 +58026 +58027 +58031 +58033 +58034 +58036 +58037 +58038 +58040 +58042 +58043 +58044 +58045 +58051 +58053 +58054 +58055 +58100 +59011 +59013 +59015 +59016 +59021 +59024 +59025 +59026 +59100 +60010 +60011 +60013 +60015 +60018 +60019 +60020 +60021 +60022 +60024 +60025 +60026 +60027 +60030 +60031 +60033 +60034 +60035 +60036 +60037 +60038 +60039 +60040 +60041 +60043 +60044 +60048 +60121 +60122 +60123 +60124 +60125 +60126 +60127 +60128 +60129 +60131 +61010 +61011 +61012 +61013 +61014 +61015 +61016 +61018 +61019 +61020 +61021 +61022 +61023 +61024 +61025 +61026 +61028 +61029 +61030 +61032 +61033 +61034 +61037 +61038 +61039 +61040 +61041 +61042 +61043 +61044 +61045 +61046 +61047 +61048 +61049 +61100 +62010 +62011 +62012 +62014 +62015 +62017 +62018 +62019 +62020 +62021 +62022 +62024 +62025 +62026 +62027 +62028 +62029 +62032 +62034 +62035 +62036 +62038 +62039 +62100 +63010 +63012 +63013 +63014 +63015 +63016 +63017 +63018 +63019 +63020 +63021 +63023 +63024 +63025 +63026 +63027 +63028 +63029 +63030 +63031 +63032 +63033 +63034 +63035 +63036 +63038 +63039 +63040 +63041 +63043 +63044 +63045 +63048 +63049 +63100 +64010 +64011 +64012 +64013 +64014 +64015 +64016 +64018 +64020 +64021 +64023 +64024 +64025 +64026 +64027 +64028 +64030 +64031 +64032 +64033 +64034 +64035 +64036 +64037 +64039 +64040 +64041 +64042 +64043 +64044 +64045 +64046 +64047 +64049 +64100 +65010 +65011 +65012 +65013 +65014 +65015 +65017 +65019 +65020 +65022 +65023 +65024 +65025 +65026 +65027 +65028 +65029 +65121 +65122 +65123 +65124 +65125 +65126 +65127 +65128 +65129 +66010 +66011 +66012 +66014 +66015 +66016 +66017 +66018 +66019 +66020 +66021 +66022 +66023 +66026 +66030 +66031 +66032 +66033 +66034 +66036 +66037 +66038 +66040 +66041 +66042 +66043 +66044 +66045 +66046 +66047 +66050 +66051 +66052 +66054 +66100 +67010 +67012 +67013 +67014 +67015 +67017 +67019 +67020 +67021 +67022 +67023 +67024 +67025 +67026 +67027 +67028 +67029 +67030 +67031 +67032 +67033 +67034 +67035 +67036 +67037 +67038 +67039 +67040 +67041 +67043 +67044 +67045 +67046 +67047 +67048 +67049 +67050 +67051 +67052 +67053 +67054 +67055 +67056 +67057 +67058 +67059 +67060 +67061 +67062 +67063 +67064 +67066 +67067 +67068 +67069 +67100 +70010 +70011 +70013 +70014 +70015 +70016 +70017 +70018 +70019 +70020 +70021 +70022 +70023 +70024 +70025 +70026 +70027 +70028 +70029 +70031 +70032 +70033 +70037 +70038 +70042 +70043 +70044 +70051 +70052 +70053 +70054 +70055 +70056 +70058 +70059 +70121 +70122 +70123 +70124 +70125 +70126 +70127 +70128 +70129 +70131 +71010 +71011 +71012 +71013 +71014 +71015 +71016 +71017 +71018 +71019 +71020 +71021 +71022 +71023 +71024 +71025 +71026 +71027 +71028 +71029 +71030 +71031 +71032 +71033 +71034 +71035 +71036 +71037 +71038 +71039 +71040 +71041 +71042 +71043 +71044 +71045 +71046 +71047 +71048 +71049 +71100 +72010 +72012 +72013 +72014 +72015 +72016 +72017 +72018 +72019 +72020 +72021 +72022 +72023 +72024 +72025 +72026 +72027 +72028 +72029 +72100 +73010 +73011 +73012 +73013 +73014 +73015 +73016 +73017 +73018 +73019 +73020 +73021 +73022 +73023 +73024 +73025 +73026 +73027 +73028 +73029 +73030 +73031 +73032 +73033 +73034 +73035 +73036 +73037 +73038 +73039 +73040 +73041 +73042 +73043 +73044 +73045 +73046 +73047 +73048 +73049 +73050 +73051 +73052 +73053 +73054 +73055 +73056 +73057 +73058 +73059 +73100 +74010 +74011 +74012 +74013 +74014 +74015 +74016 +74017 +74018 +74019 +74020 +74021 +74022 +74023 +74024 +74025 +74026 +74027 +74028 +74100 +75010 +75011 +75012 +75013 +75014 +75015 +75016 +75017 +75018 +75019 +75020 +75021 +75022 +75023 +75024 +75025 +75026 +75027 +75028 +75029 +75100 +80010 +80011 +80012 +80013 +80014 +80016 +80017 +80018 +80019 +80020 +80021 +80022 +80023 +80024 +80025 +80026 +80027 +80028 +80029 +80030 +80031 +80032 +80033 +80034 +80035 +80036 +80038 +80039 +80040 +80041 +80042 +80044 +80045 +80046 +80047 +80048 +80049 +80050 +80051 +80053 +80054 +80055 +80056 +80057 +80058 +80059 +80060 +80061 +80062 +80063 +80065 +80066 +80067 +80069 +80070 +80071 +80073 +80074 +80075 +80076 +80077 +80078 +80079 +80121 +80122 +80123 +80124 +80125 +80126 +80127 +80128 +80129 +80131 +80132 +80133 +80134 +80135 +80136 +80137 +80138 +80139 +80141 +80142 +80143 +80144 +80145 +80146 +80147 +81010 +81011 +81012 +81013 +81014 +81016 +81017 +81020 +81021 +81022 +81023 +81024 +81025 +81027 +81028 +81030 +81031 +81032 +81033 +81034 +81035 +81036 +81037 +81038 +81039 +81040 +81041 +81042 +81043 +81044 +81046 +81047 +81049 +81050 +81051 +81052 +81053 +81054 +81055 +81056 +81057 +81058 +81059 +81100 +82010 +82011 +82013 +82015 +82016 +82017 +82018 +82019 +82020 +82021 +82022 +82023 +82024 +82025 +82026 +82027 +82028 +82029 +82030 +82031 +82032 +82033 +82034 +82036 +82037 +82038 +82100 +83010 +83011 +83012 +83013 +83014 +83015 +83016 +83017 +83018 +83020 +83021 +83022 +83023 +83024 +83025 +83026 +83027 +83028 +83029 +83030 +83031 +83032 +83034 +83035 +83036 +83037 +83038 +83039 +83040 +83041 +83042 +83043 +83044 +83045 +83046 +83047 +83048 +83049 +83050 +83051 +83052 +83053 +83054 +83055 +83056 +83057 +83058 +83059 +83100 +84010 +84011 +84012 +84013 +84014 +84015 +84016 +84017 +84018 +84019 +84020 +84021 +84022 +84023 +84024 +84025 +84026 +84027 +84028 +84029 +84030 +84031 +84032 +84033 +84034 +84035 +84036 +84037 +84038 +84039 +84040 +84042 +84043 +84044 +84045 +84046 +84047 +84048 +84049 +84050 +84051 +84052 +84053 +84055 +84056 +84057 +84059 +84060 +84061 +84062 +84065 +84066 +84067 +84068 +84069 +84070 +84073 +84074 +84075 +84076 +84077 +84078 +84079 +84080 +84081 +84082 +84083 +84084 +84085 +84086 +84087 +84088 +84090 +84091 +84092 +84095 +84096 +84098 +84099 +84121 +84122 +84123 +84124 +84125 +84126 +84127 +84128 +84129 +84131 +84132 +84133 +84134 +84135 +85010 +85011 +85012 +85013 +85014 +85015 +85016 +85017 +85018 +85020 +85021 +85022 +85023 +85024 +85025 +85026 +85027 +85028 +85029 +85030 +85031 +85032 +85033 +85034 +85035 +85036 +85037 +85038 +85039 +85040 +85042 +85043 +85044 +85046 +85047 +85048 +85049 +85050 +85051 +85052 +85053 +85054 +85055 +85056 +85057 +85058 +85059 +85100 +86010 +86011 +86012 +86013 +86014 +86015 +86016 +86017 +86018 +86019 +86020 +86021 +86022 +86023 +86024 +86025 +86026 +86027 +86028 +86029 +86030 +86031 +86032 +86033 +86034 +86035 +86036 +86037 +86038 +86039 +86040 +86041 +86042 +86043 +86044 +86045 +86046 +86047 +86048 +86049 +86070 +86071 +86072 +86073 +86074 +86075 +86077 +86078 +86079 +86080 +86081 +86082 +86083 +86084 +86085 +86086 +86087 +86088 +86089 +86090 +86091 +86092 +86093 +86094 +86095 +86096 +86097 +86100 +86170 +87010 +87011 +87012 +87013 +87014 +87015 +87016 +87017 +87018 +87019 +87020 +87021 +87022 +87023 +87024 +87026 +87027 +87028 +87029 +87030 +87031 +87032 +87033 +87034 +87035 +87036 +87037 +87038 +87040 +87041 +87042 +87043 +87044 +87045 +87046 +87047 +87048 +87050 +87051 +87052 +87053 +87054 +87055 +87056 +87057 +87058 +87060 +87061 +87062 +87064 +87066 +87067 +87069 +87070 +87071 +87072 +87073 +87074 +87075 +87076 +87100 +88020 +88021 +88022 +88024 +88025 +88040 +88041 +88042 +88044 +88045 +88046 +88047 +88049 +88050 +88051 +88054 +88055 +88056 +88060 +88062 +88064 +88065 +88067 +88068 +88069 +88070 +88100 +88811 +88812 +88813 +88814 +88815 +88816 +88817 +88818 +88819 +88821 +88822 +88823 +88824 +88825 +88831 +88832 +88833 +88834 +88835 +88836 +88837 +88838 +88841 +88842 +88900 +89010 +89011 +89012 +89013 +89014 +89015 +89016 +89017 +89018 +89020 +89021 +89022 +89023 +89024 +89025 +89026 +89027 +89028 +89029 +89030 +89031 +89032 +89033 +89034 +89035 +89036 +89037 +89038 +89039 +89040 +89041 +89042 +89043 +89044 +89045 +89046 +89047 +89048 +89049 +89050 +89052 +89054 +89056 +89057 +89058 +89060 +89062 +89063 +89064 +89065 +89069 +89812 +89813 +89814 +89815 +89816 +89817 +89818 +89819 +89821 +89822 +89823 +89824 +89831 +89832 +89833 +89834 +89841 +89842 +89843 +89844 +89851 +89852 +89853 +89861 +89862 +89863 +89864 +89866 +89867 +89868 +89900 +90010 +90011 +90012 +90013 +90014 +90015 +90016 +90017 +90018 +90019 +90020 +90021 +90022 +90023 +90024 +90025 +90026 +90027 +90028 +90029 +90030 +90031 +90032 +90033 +90034 +90035 +90036 +90037 +90038 +90039 +90040 +90041 +90042 +90043 +90044 +90045 +90046 +90047 +90048 +90049 +90121 +90122 +90123 +90124 +90125 +90126 +90127 +90128 +90129 +90131 +90133 +90134 +90135 +90136 +90137 +90138 +90139 +90141 +90142 +90143 +90144 +90145 +90146 +90147 +90148 +90149 +90151 +91010 +91011 +91012 +91013 +91014 +91015 +91016 +91017 +91018 +91019 +91020 +91021 +91022 +91023 +91024 +91025 +91026 +91027 +91028 +91029 +91100 +92010 +92011 +92012 +92013 +92014 +92015 +92016 +92017 +92018 +92019 +92020 +92021 +92022 +92023 +92024 +92025 +92026 +92027 +92028 +92029 +92100 +93010 +93011 +93012 +93013 +93014 +93015 +93016 +93017 +93018 +93019 +93100 +94010 +94011 +94012 +94013 +94014 +94015 +94016 +94017 +94018 +94019 +94100 +95010 +95011 +95012 +95013 +95014 +95015 +95016 +95017 +95018 +95019 +95020 +95021 +95022 +95024 +95025 +95027 +95028 +95029 +95030 +95031 +95032 +95033 +95034 +95035 +95036 +95037 +95038 +95039 +95040 +95041 +95042 +95043 +95044 +95045 +95046 +95047 +95048 +95049 +95121 +95122 +95123 +95124 +95125 +95126 +95127 +95128 +95129 +95131 +96010 +96011 +96012 +96013 +96014 +96015 +96016 +96017 +96018 +96019 +96100 +97010 +97011 +97012 +97013 +97014 +97015 +97016 +97017 +97018 +97019 +97100 +98020 +98021 +98022 +98023 +98025 +98026 +98027 +98028 +98029 +98030 +98031 +98032 +98033 +98034 +98035 +98036 +98037 +98038 +98039 +98040 +98041 +98042 +98043 +98044 +98045 +98046 +98047 +98048 +98049 +98050 +98051 +98053 +98054 +98055 +98056 +98057 +98058 +98059 +98060 +98061 +98062 +98063 +98064 +98065 +98066 +98067 +98068 +98069 +98070 +98071 +98072 +98073 +98074 +98075 +98076 +98077 +98078 +98079 +98121 +98122 +98123 +98124 +98125 +98126 +98127 +98128 +98129 +98131 +98132 +98133 +98134 +98135 +98136 +98137 +98138 +98139 +98141 +98142 +98143 +98144 +98145 +98146 +98147 +98148 +98149 +98151 +98152 +98153 +98154 +98155 +98156 +98157 +98158 +98161 +98162 +98163 +98164 +98165 +98166 +98167 +98168 diff --git a/mapit_it/circoscrizioni.csv b/mapit_it/circoscrizioni.csv new file mode 100644 index 00000000..1cf68463 --- /dev/null +++ b/mapit_it/circoscrizioni.csv @@ -0,0 +1,32 @@ +;CIRCCAM;Piemonte 1;21 Torino +;CIRCCAM;Piemonte 2;26 Alessandria,25 Asti,103 Biella,24 Cuneo,23 Novara,110 Verbano-Cusio-Ossola,22 Vercelli +;CIRCCAM;Lombardia 1;35 Milano,111 Monza e della Brianza +;CIRCCAM;Lombardia 1;36 Bergamo,37 Brescia,33 Como,104 Lecco,34 Sondrio,32 Varese +;CIRCCAM;Lombardia 2;39 Cremona,105 Lodi,40 Mantova,38 Pavia +;CIRCCAM;Veneto 1;45 Belluno,46 Treviso,47 Venezia +;CIRCCAM;Veneto 2;48 Padova,49 Rovigo,43 Verona,44 Vicenza +;CIRCCAM;Lazio 1;78 Roma +;CIRCCAM;Lazio 2;80 Frosinone,79 Latina,77 Rieti,76 Viterbo +;CIRCCAM;Campania 1;83 Napoli +;CIRCCAM;Campania 2;84 Avellino,82 Benevento,81 Caserta,85 Salerno +;CIRCCAM;Sicilia 1;117 Agrigento,118 Caltanissetta,115 Palermo,114 Trapani +;CIRCCAM;Sicilia 2;120 Catania,119 Enna,116 Messina,121 Ragusa,122 Siracusa +;CIRCCAM;Abruzzo;89 Chieti,86 L'Aquila,88 Pescara,87 Teramo +;CIRCCAM;Basilicata;97 Matera,96 Potenza +;CIRCCAM;Calabria;99 Catanzaro,98 Cosenza,108 Crotone,100 Reggio di Calabria,109 Vibo Valentia +;CIRCCAM;Emilia-Romagna;57 Bologna,58 Ferrara,60 Forli'-Cesena,56 Modena,54 Parma,53 Piacenza,59 Ravenna,55 Reggio nell'Emilia,106 Rimini +;CIRCCAM;Friuli Venezia Giulia;51 Gorizia,101 Pordenone,52 Trieste,50 Udine +;CIRCCAM;Liguria;30 Genova,28 Imperia,31 La Spezia,29 Savona +;CIRCCAM;Marche;62 Ancona,64 Ascoli Piceno,112 Fermo,63 Macerata,61 Pesaro e Urbino +;CIRCCAM;Molise;90 Campobasso,102 Isernia +;CIRCCAM;Puglia;92 Bari,113 Barletta-Andria-Trani,94 Brindisi,91 Foggia,95 Lecce,93 Taranto +;CIRCCAM;Sardegna;125 Cagliari,130 Carbonia-Iglesias,129 Medio Campidano,124 Nuoro,128 Ogliastra,127 Olbia-Tempio,126 Oristano,123 Sassari +;CIRCCAM;Toscana;71 Arezzo,68 Firenze,73 Grosseto,69 Livorno,66 Lucca,65 Massa Carrara,70 Pisa,67 Pistoia,107 Prato,72 Siena +;CIRCCAM;Trentino-Alto Adige;41 Bolzano,42 Trento +;CIRCCAM;Umbria;74 Perugia,75 Terni +;CIRCCAM;Valle D'Aosta;27 Aosta +;CIRCEU;Nord-occidentale;7 Liguria,3 Lombardia,1 Piemonte +;CIRCEU;Nord-orientale;8 Emilia-Romagna,6 Friuli Venezia Giulia,4 Trentino-Alto Adige,5 Veneto +;CIRCEU;Centrale;12 Lazio,11 Marche,9 Toscana,10 Umbria +;CIRCEU;Meridionale;13 Abruzzo,17 Basilicata,18 Calabria,15 Campania,14 Molise,16 Puglia +;CIRCEU;Isole;20 Sardegna,19 Sicilia diff --git a/mapit_it/management/commands/mapit_IT_generate_constituencies_csv.py b/mapit_it/management/commands/mapit_IT_generate_constituencies_csv.py new file mode 100644 index 00000000..21b06041 --- /dev/null +++ b/mapit_it/management/commands/mapit_IT_generate_constituencies_csv.py @@ -0,0 +1,171 @@ +from __future__ import unicode_literals +import logging +from optparse import make_option +from django.core.management.base import NoArgsCommand +import sys +from mapit.models import Area + +__author__ = 'guglielmo' + + +class Command(NoArgsCommand): + """This management command can be used to generate + the CSV stream to import constituencies using the mapit_import_area_union tasks + + This is needed to avoid inputing manually IDs that may change from instance to instance + """ + + help = 'Generate constituencies CSV' + option_list = NoArgsCommand.option_list + ( + make_option( + '--output-file', + default='stdout', + dest='output_file', help='Path to CSV file containing the output' + ), + ) + FORMAT = "[%(asctime)s] %(levelname)s - %(message)s" + logging.basicConfig(format=FORMAT, level=logging.INFO) + + def handle_noargs(self, **options): + """ + A wrapper launching subtasks for CIRCCAM and CIRCEU + constituencies + :param options: not used + :return: void + """ + + if options['output_file'] == 'stdout': + csv_out = sys.stdout + else: + csv_out = open(options['output_file'], 'w') + + logging.info("Generating constituencies for national elections (camera)") + self.handle_circcam(file=csv_out) + + logging.info("Generating constituencies for european elections") + self.handle_circeu(file=csv_out) + + csv_out.close() + + logging.info("Finishing") + + def handle_circcam(self, file=sys.stdout): + """ + Add constituencies for political national elections at La Camera. + + :param constituencies: data structure containing definitions + :param country: the Country object to assign to all areas + :param generation: the Generation object, the areas will belong to + :return: void + """ + logging.info("Generating constituencies for la Camera's general elections") + + constituencies = [ + {'name': 'Piemonte 1', 'region_name': 'Piemonte', + 'provinces': ['Torino'], 'filter_type': 'include'}, + {'name': 'Piemonte 2', 'region_name': 'Piemonte', + 'provinces': ['Torino'], 'filter_type': 'exclude'}, + {'name': 'Lombardia 1', 'region_name': 'Lombardia', + 'provinces': ['Milano', 'Monza e della Brianza'], 'filter_type': 'include'}, + {'name': 'Lombardia 1', 'region_name': 'Lombardia', + 'provinces': ['Bergamo', 'Brescia', 'Como', 'Sondrio', 'Varese', 'Lecco'], 'filter_type': 'include'}, + {'name': 'Lombardia 2', 'region_name': 'Lombardia', + 'provinces': ['Pavia', 'Lodi', 'Cremona', 'Mantova'], 'filter_type': 'include'}, + {'name': 'Veneto 1', 'region_name': 'Veneto', + 'provinces': ['Venezia', 'Treviso', 'Belluno'], 'filter_type': 'include'}, + {'name': 'Veneto 2', 'region_name': 'Veneto', + 'provinces': ['Venezia', 'Treviso', 'Belluno'], 'filter_type': 'exclude'}, + {'name': 'Lazio 1', 'region_name': 'Lazio', + 'provinces': ['Roma'], 'filter_type': 'include'}, + {'name': 'Lazio 2', 'region_name': 'Lazio', + 'provinces': ['Roma'], 'filter_type': 'exclude'}, + {'name': 'Campania 1', 'region_name': 'Campania', + 'provinces': ['Napoli'], 'filter_type': 'include'}, + {'name': 'Campania 2', 'region_name': 'Campania', + 'provinces': ['Napoli'], 'filter_type': 'exclude'}, + {'name': 'Sicilia 1', 'region_name': 'Sicilia', + 'provinces': ['Palermo', 'Trapani', 'Agrigento', 'Caltanissetta'], 'filter_type': 'include'}, + {'name': 'Sicilia 2', 'region_name': 'Sicilia', + 'provinces': ['Palermo', 'Trapani', 'Agrigento', 'Caltanissetta'], 'filter_type': 'exclude'}, + ] + for const in constituencies: + self.emit_csv( + {'parent_area__type__code': 'REG', + 'parent_area__name': const['region_name']}, + 'CIRCCAM', const['name'], + const['provinces'], + filter_type=const['filter_type'], file=file + ) + + regioni_names = Area.objects.filter(type__code='REG').exclude( + name__in=( + 'Piemonte', 'Lombardia', 'Veneto', + 'Lazio', 'Campania', 'Sicilia' + ) + ).values_list('name', flat=True) + for name in regioni_names: + self.emit_csv( + {'parent_area__name': name, + 'parent_area__type__code': 'REG'}, + 'CIRCCAM', name, [], + filter_type='all', file=file + ) + + def handle_circeu(self, file=sys.stdout): + """ + Add constituencies for european elections. + :return: string + """ + + logging.info("Generating constituencies for European Parliament's elections") + + constituencies = [ + {'name': 'Nord-occidentale', + 'regions': ["Valle d'Aosta", "Liguria", "Piemonte", "Lombardia"]}, + {'name': 'Nord-orientale', + 'regions': ["Emilia-Romagna", "Friuli Venezia Giulia", "Trentino-Alto adige", "Veneto"]}, + {'name': 'Centrale', + 'regions': ["Toscana", "Umbria", "Marche", "Lazio"]}, + {'name': 'Meridionale', + 'regions': ["Abruzzo", "Molise", "Campania", "Basilicata", "Puglia", "Calabria"]}, + {'name': 'Isole', + 'regions': ["Sicilia", "Sardegna"]}, + ] + for const in constituencies: + self.emit_csv( + {'type__code': 'REG'}, + 'CIRCEU', const['name'], + const['regions'], + filter_type='include', file=file + ) + + def emit_csv(self, old_areas_filters, const_code, const_name, old_areas_names, filter_type='all', file=sys.stdout): + """ + Emit CSV line to file + + :param parent_area_filters: dict - django-orm filters to select the parent area, as dict + ('name': 'Lombardia', 'type__code': 'REG') + :param circ_code: string - New constitution code (CIRCCAM) + :param circ_name: string - New constitution name (Piemonte 1) + :param old_areas_names: list - List or Tuple of old areas names (must be uniques among old_area children) + :param filter_type: string - Type of filter (may be 'all', 'include' or 'exclude' + :param file: file - the file the stream must be sent to + :return: void + """ + + r = Area.objects.filter(**old_areas_filters) + new_area_csv = ";{0};{1};".format(const_code, const_name) + if filter_type == 'all': + old_areas_csv = ",".join(["{0} {1}".format(id, name) for id, name in r.values_list('id', 'name')]) + elif filter_type == 'exclude': + r = r.exclude(name__in=old_areas_names).values_list('id', 'name') + old_areas_csv = ",".join(["{0} {1}".format(id, name) for id, name in r]) + else: + r = r.filter(name__in=old_areas_names).values_list('id', 'name') + old_areas_csv = ",".join(["{0} {1}".format(id, name) for id, name in r]) + + file.write( + new_area_csv + + old_areas_csv + + "\n" + ) diff --git a/mapit_it/management/commands/mapit_IT_import_postal_codes.py b/mapit_it/management/commands/mapit_IT_import_postal_codes.py new file mode 100644 index 00000000..912a21b9 --- /dev/null +++ b/mapit_it/management/commands/mapit_IT_import_postal_codes.py @@ -0,0 +1,63 @@ +# This is a generic script for importing postal codes in some format from a CSV +# file. The CSV file should have the following columns: +# Postal code, Latitude, Longitude +# By default in those positions, though you can specify other column numbers on +# the command line + +from optparse import make_option +from django.contrib.gis.geos import Point +import requests +import time +from mapit.management.commands.mapit_import_postal_codes import Command as pcCommand + + +class Command(pcCommand): + help = 'Import Postal codes from a CSV file or files' + args = '' + count = {'total': 0, 'updated': 0, 'unchanged': 0, 'created': 0} + often = 10 + nominatim_url = "http://nominatim.openstreetmap.org/" + + def create_parser(self, prog_name, subcommand): + parser = super(Command, self).create_parser(prog_name, subcommand) + parser.set_defaults(**{'coord-field-lat': None, 'coord-field-lon': None}) + return parser + + option_list = pcCommand.option_list + ( + make_option( + '--nominatim-sleep-time', + action="store", + dest='nominatim-sleep-time', + default="0.25", + help='The n. of seconds to wait before two subsequent requests' + ), + ) + + def handle_row(self, row, options): + if not options['location']: + return self.do_postcode() + + if not options['coord-field-lat']: + # request lat and lon to nominatim + req = "{0}search?format=json&country=it&postalcode={1}".format( + self.nominatim_url, self.code + ) + try: + print u"Requesting {0}".format(req) + r = requests.get(req).json()[0] + lat = float(r['lat']) + lon = float(r['lon']) + except Exception as e: + print u"Exception: {0}".format(e) + print u"Skipping." + return + # sleep before successive request + time.sleep(float(options['nominatim-sleep-time'])) + else: + if not options['coord-field-lon']: + options['coord-field-lon'] = int(options['coord-field-lat']) + 1 + lat = float(row[int(options['coord-field-lat']) - 1]) + lon = float(row[int(options['coord-field-lon']) - 1]) + srid = int(options['srid']) + location = Point(lon, lat, srid=srid) + return self.do_postcode(location, srid)