Commit e908a3a1 authored by Grégoire PETIT's avatar Grégoire PETIT
Browse files

exportimport

parent 89d34564
......@@ -8,12 +8,12 @@ from math import atan, pi
from matplotlib import pyplot
#input_filename_altitude="D:/documents/IMT/datascience/challenge3/moodle/altitude-map.bmp"
input_filename_altitude="../moodle/altitude-map.bmp"
input_filename_altitude="D:/documents/IMT/datascience/challenge3/moodle/altitude-map.bmp"
#input_filename_altitude="../moodle/altitude-map.bmp"
im_alt = Image.open(input_filename_altitude)
#input_filename_poputation="D:/documents/IMT/datascience/challenge3/moodle/population-density-map.bmp"
input_filename_poputation="../moodle/population-density-map.bmp"
input_filename_poputation="D:/documents/IMT/datascience/challenge3/moodle/population-density-map.bmp"
#input_filename_poputation="../moodle/population-density-map.bmp"
im_pop = Image.open(input_filename_poputation)
......@@ -392,15 +392,8 @@ def stepThree(Graph):
#20 Itérations
for i in range(500):
print(stepThree(Graph)[88][52], len(Graph), len(Graph[0]))
print(stepThree(Graph)[87][43], len(Graph), len(Graph[0]))
print('Jour', i+1, 'terminé!')
print(Graph[2103//15:229])
import csv
abc=[[[1,2,[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4]],[7,8,[10,11,121,13,14,15,61,7,181,191,101,111,121,131,14]]]]
def exportgraphe(graphe):
flat=[]
for line in graphe:
flat+=line
with open("D:/documents/IMT/datascience/challenge3/moodle/graphe.csv", 'a') as outcsv:
#configure writer to write standard csv file
writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
for item in flat:
#Write item to outcsv
writer.writerow([item[0], item[1], item[2][0], item[2][1], item[2][2], item[2][3], item[2][4], item[2][5], item[2][6], item[2][7], item[2][8], item[2][9], item[2][10], item[2][11], item[2][12], item[2][13], item[2][14]])
exportgraphe(abc)
def importgraphe(nbline,nbcol):
with open("D:/documents/IMT/datascience/challenge3/moodle/graphe.csv",newline='') as f:
reader = csv.reader(f,delimiter=',')
uidlist = list(reader)
res=[[[] for _ in range(nbcol)] for _ in range(nbline)]
compteur=0
for line in uidlist:
res[compteur%nbline][compteur//nbline].append(int(line[0]))
res[compteur%nbline][compteur//nbline].append(int(line[1]))
res[compteur%nbline][compteur//nbline].append([int(elt) for elt in line[2:]])
compteur+=1
return(res)
test=importgraphe(1,2)
print(test)
\ No newline at end of file
1,2,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4
7,8,10,11,121,13,14,15,61,7,181,191,101,111,121,131,14
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment