Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'jbjares'
- import csv
- import re
- import sys
- def isGreaterThenZeroDotFive(number,actualRow,actualColumn):
- try:
- if float(number) > float(0.5):
- print(number,actualRow,actualColumn)
- except NameError:
- pass
- return False
- with open('gene.matrix.csv', newline='') as csvfile:
- spamreader = csv.reader(csvfile, delimiter='"', quotechar=',')
- columnsName = list()
- rowsName = list()
- countRows = 0
- actualColumn = 0
- for row in spamreader:
- for content in row:
- if countRows == 0 and len(columnsName) < 16 and content!='':
- columnsName.append(content)
- continue
- # Cleaning empty and string fields
- if content == '':
- continue
- if actualColumn<=16:
- actualColumn = actualColumn+1
- if actualColumn==16:
- actualColumn = 0;
- if countRows==0:
- countRows = countRows+1
- #avoid numbers as list of char
- if countRows>0 and len(content)<30:
- rowsName.append(content)
- result = re.search('[a-zA-Z]+',content)
- #just to avoid not numbers
- if result != None:
- continue
- #Start processment, just for numbers.
- else:
- try:
- words = content.split(',')
- for word in words:
- if(isinstance(word, str)):
- #treatment for found special case
- specialCaseWords = word.split('.')
- lenf = len(specialCaseWords)
- if lenf >= 3:
- firstWord = None
- restWord = None
- middleWord = None
- afterSecondDotWord = None
- fixedNumberA = None
- fixedNumberB = None
- count = 1
- for specialCaseWord in specialCaseWords:
- if count == 1 and firstWord == None:
- firstWord = specialCaseWord
- if count == 2 and firstWord != None:
- lenfStart = len(specialCaseWord)-1
- lenfFinal = len(specialCaseWord)
- restWord = specialCaseWord[lenfStart:lenfFinal]
- middleWord = specialCaseWord[0:lenfStart]
- if count == 3 and firstWord != None:
- afterSecondDotWord = specialCaseWord
- count = count+1
- if(count==4):
- fixedNumberA = firstWord+'.'+middleWord
- fixedNumberB = restWord+'.'+afterSecondDotWord
- isGreaterThenZeroDotFive(fixedNumberA,countRows,actualColumn)
- actualColumn = actualColumn+1;
- isGreaterThenZeroDotFive(fixedNumberB,countRows,actualColumn)
- actualColumn = actualColumn+1;
- count = count+1
- else:
- isGreaterThenZeroDotFive(word,countRows,actualColumn)
- countRows = countRows+1
- except NameError:
- pass
- #print(columnsName+" "+rowsName)
- print(rowsName)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement