# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ #Diana Suciu import csv import numpy import scipy import inspect def csv_reader(file_obj): #reads entire CSV file i=1 reader=csv.DictReader(file_obj) reader=csv.reader(file_obj,delimiter=';') with open(file_obj) as f: # print (f) #doesnt work, dont need to print # f.close for line in f: f.readline() print (line,) #csv_reader(sample.csv) #file=open('/home/suciud/Desktop/suciud/openknee/utl/PressureAnalysis/sample.csv','r') #csv_reader('/home/suciud/Documents/OKRepository/utl/PressureAnalysis/sample.csv') def find_largest(file_obj): #found the largest and smallest value in ALL of the file, not needed any more. value=[] #find out how to separate the matrixes later with open(file_obj) as f: for line in f: f.readline() value=line.split(",")[0] if value != '@' and value != ' ': max_value=max(value) print("max value is") print (max_value) min_value=min(value) print ("min value is") print(min_value) return max_value f.close #find_largest('/home/suciud/Documents/OKRepository/utl/PressureAnalysis/sample.csv') def find_sum(file_obj): #this found the sum of ALL Values given, not needed any more. value=0 with open(file_obj) as f: for line in f: f.readline() for num in line: value= value + ord(num) #print (value) print("summation is") print(value) return value #find_sum('/home/suciud/Documents/OKRepository/utl/PressureAnalysis/sample.csv') def find_frame(file_obj): #this is a test to see if the reader was reading all of the Frames i=1 with open(file_obj)as file: for line in file: for part in line.split(): if "Frame" in part: #print (part) #print(line) print(i) i=i+1 return i #found 25 frames in sample, good find_frame('/home/suciud/Documents/OKRepository/utl/PressureAnalysis/sample.csv') #for each frame itterate through the matrix that follows #start by going through one matrix def frame1(file_obj): #to get the row length and line number start of frame #later make this applicable for other frames i=1 with open(file_obj)as file: for num,line in enumerate(file,1): if "Frame" in line: #print (num) break #print(line) # print(i) #i=i+1 # if "ROWS" in part: # print(line) ##figure out how to pull the value "44" from rows, but for now assume you have 44 rows return num #frame1('/home/suciud/Documents/OKRepository/utl/PressureAnalysis/sample.csv') def readsection(file_obj):#I'm pretty sure this is usless by now, but leaving as proof of thought process #split a section into lines, this particular section reads the matrix of frame 1 (lines 42-86). #in future make line range enterable, or gotten from other parts of code num=frame1(file_obj) i=0 reader=csv.DictReader(file_obj) reader=csv.reader(file_obj,delimiter=';') with open(file_obj) as f: # print (f) #doesnt work, dont need to print # f.close for line in f: i+=1 #f.readline() if i>num-1 and inum+1 and inum+1 and inum+1 and i