-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSVFuncs.py
More file actions
50 lines (43 loc) · 1.21 KB
/
CSVFuncs.py
File metadata and controls
50 lines (43 loc) · 1.21 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 29 00:26:03 2017
@author: wheelspawn
"""
import csv
import numpy as np
def csvToWeights(path):
listy=[]
with open(path) as csvfile:
myReader = csv.reader(csvfile, delimiter=',')
for row in myReader:
n=[]
for item in row:
p = item.split(',')
p = (list(float(i) for i in p if i != ''))
if p != []:
n.append(p)
listy.append(np.array(n))
csvfile.close()
return listy
def weightsToCsv(weights, name):
with open(name, "w+") as csvfile:
myWriter = csv.writer(csvfile,delimiter=',')
print(weights)
for row in weights:
myWriter.writerow(row)
csvfile.close()
def vectorsToArray(path):
listy=[]
with open(path) as csvfile:
myReader = csv.reader(csvfile, delimiter=',')
for row in myReader:
n=[]
for item in row:
p = item.split(',')
p = (list(float(i) for i in p if i != ''))
if p != []:
n.extend(p)
listy.append(n)
csvfile.close()
return listy