Skip to content

Commit

Permalink
Add somej code
Browse files Browse the repository at this point in the history
  • Loading branch information
eebersol committed Mar 16, 2019
1 parent 29d9384 commit 425e83f
Show file tree
Hide file tree
Showing 3 changed files with 2,410 additions and 2,402 deletions.
20 changes: 14 additions & 6 deletions parse.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import copy

finallist = [] # variable global permettant de stocker la liste final

def rmv_b(country): # Permet de supprimer le b' qui ce met souvent en general avant le nom du pays, ceci a un rapport avec le type de la variables qui serait un byte ?
Expand Down Expand Up @@ -31,14 +33,19 @@ def print_result_per_country(country, fd): # Merge les differentes annees pour u
def get_average_per_year(dataset, country, year): # Merge les differentes data pour un meme pays et une meme date
suicide = 0
population = 0
tmp = copy.copy(dataset)
j = 0

for line in dataset:
line = str(line).split(",")
for line in tmp:
toto = str(line).split(",")
# Si c'est le bon pays et la bonne anée alors tu concats les informations
if country == rmv_b(line[0]) and year == int(line[1]):
suicide += int(line[4])
population += int(line[5])

if country == rmv_b(toto[0]) and year == int(toto[1]):
suicide += int(toto[4])
population += int(toto[5])
del dataset[j]
j += 1

# print(len(dataset))
finallist.append({
'country' : country,
'year' : year,
Expand Down Expand Up @@ -74,6 +81,7 @@ def get_country(dataset): # Recupère la liste de pays
country = rmv_b(country)
print(country, str(i) + "/" + str(lencountries))
get_average_per_year(dataset, country, 1985)
print(len(dataset))
i += 1

# Print le resultat de la merge
Expand Down
196 changes: 98 additions & 98 deletions result_per_country.txt
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
country, percent_average, suicide_average
Albania,0.0033,89.54545454545455
Antigua and Barbuda,0.0004,0.4074074074074074
Argentina,0.0067,2652.2258064516127
Armenia,0.0032,76.2
Aruba,0.0076,7.214285714285714
Australia,0.0105,2337.0333333333333
Austria,0.0209,1564.78125
Azerbaijan,0.0013,103.5
Bahamas,0.0012,4.043478260869565
Bahrain,0.0018,22.047619047619047
Barbados,0.0027,7.08
Belarus,0.0320,2852.0
Belgium,0.0191,2024.5483870967741
Belize,0.0039,12.428571428571429
Bosnia and Herzegovina,0.0044,159.0
Brazil,0.0038,7310.096774193548
Bulgaria,0.0176,1212.9333333333334
Cabo Verde,0.0093,42.0
Canada,0.0111,3709.0
Chile,0.0080,1319.1935483870968
Colombia,0.0038,1712.258064516129
Costa Rica,0.0051,226.4
Croatia,0.0235,837.6818181818181
Cuba,0.0159,1725.75
Cyprus,0.0039,27.466666666666665
Czech Republic,0.0181,1618.037037037037
Denmark,0.0129,695.3181818181819
Albania,0.0027,52.63636363636363
Antigua and Barbuda,0.0001,0.07407407407407407
Argentina,0.0052,1413.9032258064517
Armenia,0.0025,40.44
Aruba,0.0063,3.2857142857142856
Australia,0.0082,1168.0666666666666
Austria,0.0173,762.75
Azerbaijan,0.0010,57.0
Bahamas,0.0008,1.608695652173913
Bahrain,0.0011,9.476190476190476
Barbados,0.0020,3.08
Belarus,0.0251,1488.857142857143
Belgium,0.0183,1143.967741935484
Belize,0.0026,5.892857142857143
Bosnia and Herzegovina,0.0030,69.5
Brazil,0.0029,3774.935483870968
Bulgaria,0.0144,685.3333333333334
Cabo Verde,0.0083,24.0
Canada,0.0093,1706.3793103448277
Chile,0.0064,695.5483870967741
Colombia,0.0030,916.1290322580645
Costa Rica,0.0034,109.0
Croatia,0.0184,436.1363636363636
Cuba,0.0123,878.6666666666666
Cyprus,0.0028,12.533333333333333
Czech Republic,0.0173,857.7407407407408
Denmark,0.0113,350.8181818181818
Dominica,0.0000,0.0
Ecuador,0.0046,666.4516129032259
El Salvador,0.0085,486.7916666666667
Estonia,0.0269,334.95238095238096
Fiji,0.0035,27.636363636363637
Finland,0.0224,1161.2758620689656
France,0.0182,10970.9
Georgia,0.0042,146.54545454545453
Germany,0.0143,11202.384615384615
Greece,0.0039,398.96774193548384
Grenada,0.0018,1.4615384615384615
Guatemala,0.0019,271.6333333333333
Guyana,0.0200,137.04
Hungary,0.0339,2841.9615384615386
Iceland,0.0129,34.625
Ireland,0.0097,419.1333333333333
Israel,0.0048,364.3225806451613
Italy,0.0073,4260.0
Jamaica,0.0004,10.823529411764707
Japan,0.0216,26029.09677419355
Kazakhstan,0.0250,3905.6153846153848
Kiribati,0.0065,4.818181818181818
Kuwait,0.0010,38.64
Kyrgyzstan,0.0097,503.46153846153845
Latvia,0.0324,608.0952380952381
Lithuania,0.0521,1274.5
Luxembourg,0.0117,63.16129032258065
Macau,0.0078,27.0
Maldives,0.0006,2.0
Malta,0.0046,18.870967741935484
Mauritius,0.0123,121.6875
Mexico,0.0031,3585.1290322580644
Mongolia,0.0195,423.0
Montenegro,0.0080,47.2
Netherlands,0.0112,1588.53125
New Zealand,0.0120,495.9655172413793
Nicaragua,0.0061,335.5
Norway,0.0116,566.4
Oman,0.0003,11.0
Panama,0.0039,139.32
Paraguay,0.0030,177.14814814814815
Philippines,0.0017,1422.0
Poland,0.0161,5795.75
Portugal,0.0090,891.1481481481482
Puerto Rico,0.0084,291.7096774193548
Qatar,0.0017,38.266666666666666
Republic of Korea,0.0173,8442.90322580645
Romania,0.0156,2599.1785714285716
Russian Federation,0.0327,44805.25925925926
Ecuador,0.0036,354.61290322580646
El Salvador,0.0067,250.625
Estonia,0.0204,176.52380952380952
Fiji,0.0027,14.454545454545455
Finland,0.0160,580.3103448275862
France,0.0151,5894.133333333333
Georgia,0.0033,77.81818181818181
Germany,0.0101,5330.653846153846
Greece,0.0030,210.4516129032258
Grenada,0.0010,0.46153846153846156
Guatemala,0.0014,142.43333333333334
Guyana,0.0158,68.44
Hungary,0.0264,1455.0
Iceland,0.0099,15.71875
Ireland,0.0068,200.36666666666667
Israel,0.0037,202.03225806451613
Italy,0.0057,2213.3548387096776
Jamaica,0.0003,4.764705882352941
Japan,0.0189,13829.225806451614
Kazakhstan,0.0168,1916.8846153846155
Kiribati,0.0042,1.9090909090909092
Kuwait,0.0007,17.12
Kyrgyzstan,0.0072,246.15384615384616
Latvia,0.0247,291.4761904761905
Lithuania,0.0388,550.3181818181819
Luxembourg,0.0097,32.41935483870968
Macau,0.0057,14.0
Maldives,0.0003,0.6
Malta,0.0039,8.419354838709678
Mauritius,0.0099,60.65625
Mexico,0.0023,1999.0645161290322
Mongolia,0.0140,190.0
Montenegro,0.0069,26.5
Netherlands,0.0105,862.5
New Zealand,0.0105,248.06896551724137
Nicaragua,0.0044,178.33333333333334
Norway,0.0105,306.0
Oman,0.0003,6.0
Panama,0.0027,72.32
Paraguay,0.0027,102.81481481481481
Philippines,0.0012,813.1333333333333
Poland,0.0109,2590.3333333333335
Portugal,0.0081,471.81481481481484
Puerto Rico,0.0061,143.80645161290323
Qatar,0.0017,16.333333333333332
Republic of Korea,0.0144,5609.548387096775
Romania,0.0145,1170.1785714285713
Russian Federation,0.0232,21456.074074074073
Saint Kitts and Nevis,0.0000,0.0
Saint Lucia,0.0050,8.214285714285714
Saint Vincent and Grenadines,0.0049,4.96
San Marino,0.0047,1.3333333333333333
Serbia,0.0199,1343.2777777777778
Seychelles,0.0063,5.444444444444445
Singapore,0.0088,325.4516129032258
Slovakia,0.0119,610.7727272727273
Slovenia,0.0259,505.4761904761905
South Africa,0.0007,366.05
Spain,0.0073,3232.3225806451615
Sri Lanka,0.0283,5058.272727272727
Suriname,0.0155,77.35714285714286
Sweden,0.0155,1259.8333333333333
Switzerland,0.0158,1248.4285714285713
Thailand,0.0074,3951.535714285714
Trinidad and Tobago,0.0121,149.59259259259258
Turkey,0.0020,1447.2857142857142
Turkmenistan,0.0061,297.37931034482756
Ukraine,0.0283,11426.785714285714
United Arab Emirates,0.0013,103.66666666666667
United Kingdom,0.0072,4413.064516129032
United States,0.0111,33355.25806451613
Uruguay,0.0147,469.2142857142857
Saint Lucia,0.0039,3.4285714285714284
Saint Vincent and Grenadines,0.0029,1.8
San Marino,0.0017,0.3333333333333333
Serbia,0.0172,808.3333333333334
Seychelles,0.0058,2.5
Singapore,0.0080,187.58064516129033
Slovakia,0.0083,305.1818181818182
Slovenia,0.0180,245.38095238095238
South Africa,0.0006,191.05
Spain,0.0067,1666.2903225806451
Sri Lanka,0.0215,2848.181818181818
Suriname,0.0117,40.5
Sweden,0.0143,678.3
Switzerland,0.0145,674.952380952381
Thailand,0.0056,2034.857142857143
Trinidad and Tobago,0.0085,77.44444444444444
Turkey,0.0015,863.8571428571429
Turkmenistan,0.0044,142.24137931034483
Ukraine,0.0236,6053.892857142857
United Arab Emirates,0.0015,39.166666666666664
United Kingdom,0.0064,2211.032258064516
United States,0.0099,19144.935483870966
Uruguay,0.0108,247.10714285714286
Loading

0 comments on commit 425e83f

Please sign in to comment.