forked from ChaoticRoman/numpy_scipy_matplotlib_workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data.py
More file actions
33 lines (23 loc) · 740 Bytes
/
load_data.py
File metadata and controls
33 lines (23 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import numpy as np
from datetime import datetime as dt
fn = "klementinum.csv"
def load_data():
with open(fn) as f:
header = f.readline()
header = [l.strip() for l in header.split(",")]
data = np.genfromtxt(fn, delimiter=',', skip_header=1)
L = data.shape[0]
cols2date = lambda i: dt(*map(int, data[i, :3]))
dates = np.array([cols2date(i) for i in range(L)])
return header[3:7], dates, data[:, 3:7]
def view_array(x, n=3):
L = x.shape[0]
[print(x[i]) for i in range(n)]
print("...")
[print(x[L-n+i]) for i in range(n)]
if __name__ == "__main__":
header, dates, data = load_data()
view_array(dates)
print(header)
view_array(data)
print(dates.dtype, data.dtype)