Changeset aa749ac in sasview for DataLoader/readers
- Timestamp:
- Jul 2, 2008 9:30:33 AM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 70e9610
- Parents:
- cbe6dbe
- Location:
- DataLoader/readers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/readers/TXT2_Reader.py
r11a0319 raa749ac 18 18 """ Store the values loaded from file in local variables """ 19 19 if not path == None: 20 input_f = open(path,'r') 21 buff = input_f.read() 22 lines = buff.split('\n') 23 self.x=[] 24 self.y=[] 25 self.dx = [] 26 self.dy=[] 27 value="can't read" 28 for line in lines: 29 toks = line.split() 30 try: 31 x = float(toks[0]) 32 self.x.append(x) 33 except: 34 print "READ ERROR", line 35 try: 36 y = float(toks[1]) 37 self.y.append(y) 38 except: 39 print "READ ERROR", line 40 try: 41 dy=float(toks[2]) 42 self.dy.append(dy) 43 44 except: 45 print "READ ERROR", line 46 47 if(( self.x==[])or (self.y==[])) or (self.dy !=[]): 48 print "went here" 49 #return value 50 raise ValueError, "Reader1 can't read" 20 read_it = False 21 ext=['.txt','.dat'] 22 for item in ext: 23 if path.lower().find(item)>=0: 24 read_it = True 25 #print "this is the flag",read_it, path.lower() 26 if read_it==False: 27 return None 51 28 else: 52 #msg="R1 reading: \n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 53 #return msg 54 print "TXT2_Reader reading: \n" 55 return self.x,self.y,self.dy 56 29 input_f = open(path,'r') 30 buff = input_f.read() 31 lines = buff.split('\n') 32 self.x=[] 33 self.y=[] 34 self.dx = [] 35 self.dy=[] 36 for line in lines: 37 toks = line.split() 38 try: 39 x = float(toks[0]) 40 self.x.append(x) 41 except: 42 pass 43 #print "READ ERROR", line 44 try: 45 y = float(toks[1]) 46 self.y.append(y) 47 except: 48 pass 49 #print "READ ERROR", line 50 try: 51 dy=float(toks[2]) 52 self.dy.append(dy) 53 54 except: 55 pass 56 #print "READ ERROR", line 57 58 if(( self.x==[])or (self.y==[])) or (self.dy !=[]): 59 #print "went here" 60 #return value 61 raise ValueError, "TXT2_Reader can't read" 62 else: 63 #msg="R1 reading: \n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" 64 #return msg 65 print "TXT2_Reader reading \n" 66 return self.x,self.y,self.dy 67 return None 57 68 58 69 -
DataLoader/readers/TXT3_Reader.py
rbb03739 raa749ac 27 27 if path.lower().find(item)>=0: 28 28 read_it = True 29 print "this is the flag",read_it, path.lower()29 #print "this is the flag",read_it, path.lower() 30 30 if read_it==False: 31 r aise ValueError, "txtReader can't read"31 return None 32 32 else: 33 33 input_f = open(path,'r') … … 38 38 self.dx = [] 39 39 self.dy=[] 40 value="can't read"41 40 for line in lines: 42 41 toks = line.split() … … 51 50 52 51 except: 53 print "READ ERROR", line 52 pass 53 #print "READ ERROR", line 54 54 55 55 self.dx = numpy.zeros(len(self.x)) … … 61 61 62 62 if (self.x==[] or self.y==[])and (self.dy==[]): 63 raise ValueError, " txtReader can't read"63 raise ValueError, "TXT3_Reader can't read" 64 64 else: 65 65 #msg="txtReader Reading:\n"+"this x :"+ str(self.x) +"\n"+"this y:"+str(self.y)+"\n"+"this dy :"+str(self.dy)+"\n" … … 68 68 return self.x,self.y,self.dy 69 69 70 70 return None 71 71 if __name__ == "__main__": 72 72 read= Reader()
Note: See TracChangeset
for help on using the changeset viewer.