forked from aralab-unr/GA-mammograms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_mixed_csv.py
35 lines (22 loc) · 889 Bytes
/
read_mixed_csv.py
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
##-------------------------------------------
import numpy as np
def read_mixed_csv(fileName = None,delimiter = None):
fid = open(fileName,'r')
lineArray = cell(100,1)
## larger than is needed)
lineIndex = 1
nextLine = fgetl(fid)
while not nextLine==- 1 :
lineArray[lineIndex] = nextLine
lineIndex = lineIndex + 1
nextLine = fgetl(fid)
fid.close()
lineArray = lineArray(np.arange(1,lineIndex - 1+1))
for iLine in np.arange(1,lineIndex - 1+1).reshape(-1):
lineData = textscan(lineArray[iLine],'%s','Delimiter',delimiter)
lineData = lineData[0]
if str(lineArray[iLine](end())) == str(delimiter):
lineData[end() + 1] = ''
lineArray[iLine,np.arange[1,np.asarray[lineData].size+1]] = lineData
return lineArray
return lineArray