Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Grégoire PETIT
DataScience
Commits
e908a3a1
Commit
e908a3a1
authored
Dec 05, 2018
by
Grégoire PETIT
Browse files
exportimport
parent
89d34564
Changes
3
Hide whitespace changes
Inline
Side-by-side
Challenge3/code/challenge3.py
View file @
e908a3a1
...
...
@@ -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
)[
8
8
][
52
],
len
(
Graph
),
len
(
Graph
[
0
]))
print
(
stepThree
(
Graph
)[
8
7
][
43
],
len
(
Graph
),
len
(
Graph
[
0
]))
print
(
'Jour'
,
i
+
1
,
'terminé!'
)
print
(
Graph
[
2103
//
15
:
229
])
Challenge3/code/importexport.py
0 → 100644
View file @
e908a3a1
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
Challenge3/moodle/graphe.csv
0 → 100644
View file @
e908a3a1
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment