Daniel Varga commited on
Commit
b7c921e
·
1 Parent(s): 59edc08

dealing with gz

Browse files
Files changed (1) hide show
  1. geotag/geomap.py +12 -8
geotag/geomap.py CHANGED
@@ -1,5 +1,7 @@
1
  import numpy as np
2
  import folium
 
 
3
 
4
 
5
  BASE_URL = "https://static.renyi.hu/ai-shared/daniel/sameenergy/"
@@ -8,14 +10,16 @@ RADIUS = 1e9 # 0.01
8
 
9
  def read_data():
10
  data = []
11
- for l in open("PhotoLibrary.854G.geotags", "r"):
12
- a = l.strip().split("\t")
13
- if len(a) == 2:
14
- assert a[1] == "no"
15
- elif a[1] == "nan" or a[2] == "nan":
16
- pass
17
- else:
18
- data.append(a)
 
 
19
  data = np.array(data, dtype=object)
20
  coords = np.array(data[:, 1:], dtype=np.float32)
21
  filenames = data[:, 0]
 
1
  import numpy as np
2
  import folium
3
+ import gzip
4
+ import io
5
 
6
 
7
  BASE_URL = "https://static.renyi.hu/ai-shared/daniel/sameenergy/"
 
10
 
11
  def read_data():
12
  data = []
13
+ with gzip.open("PhotoLibrary.854G.geotags.gz", "rb") as gz_file:
14
+ gz_file = io.TextIOWrapper(gz_file)
15
+ for l in gz_file:
16
+ a = l.strip().split("\t")
17
+ if len(a) == 2:
18
+ assert a[1] == "no"
19
+ elif a[1] == "nan" or a[2] == "nan":
20
+ pass
21
+ else:
22
+ data.append(a)
23
  data = np.array(data, dtype=object)
24
  coords = np.array(data[:, 1:], dtype=np.float32)
25
  filenames = data[:, 0]