summaryrefslogtreecommitdiff
path: root/plot.py
blob: 1669c5a13e4a37e5a62aa6deab217e87377dbff9 (plain)
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
import csv
import os
import re

import matplotlib.pyplot as plot


def load(directory):
	def _read(iterable):
		for x, y in iterable:
			yield float(x), float(y)

	def _load(filename):
		with open(filename) as fd:
			reader = csv.reader(fd)
			return list(_read(reader))

	def _files(directory):
		for file in os.listdir(directory):
			match = re.match(r"SWI_(-?\d+)\.csv", file)
			if match:
				yield int(match.group(1)), os.path.join(directory, file)

	return [(x, _load(y)) for x, y in _files(directory)]


swis = load("dataset")

for index, data in swis:
	plot.plot([x[0] for x in data], [x[1] for x in data], label=index)
plot.show()