def validatemanualtestpoints(self, _testpoints='', _testpointlist=[]): """ # Check if point test text exists and valid, if yes, add to test point list. :param _testpoints: :param _testpointlist: :return: tstpoint list and status """ manualtestpoints = _testpoints #Placing arg into var try: listofpoints = manualtestpoints.split("|") #Using pipe as delimiter, get the coord sets for pointstr in listofpoints: #For each coord pointxy = pointstr.split(",") #Get the x and y in array point = Geom.Point(pointxy[0], pointxy[1]) #Create a Geometry Point _testpointlist.append(point) #Add the geometry Point into the list of test points return _testpointlist, True except Exception: return _testpointlist, False pass
def __read_csv_data(self, _filepath): """ This call, 1. Read the CSV file and perform simple validation of content 2. Returns a list of points :param _inputfilepath: :return: """ status = 0 pointsList=[] try: with open(_filepath, 'r') as csvFile: #Open csv file read only readin = csv.reader(csvFile, delimiter=',') #Use csvreader for row in readin: #Each row has x,y only if (len(row)>=2): newPoint = Geom.Point(_x=row[0],_y=row[1]) #If each row has 2 elements, then use the 1st and 2nd elements as Point pointsList.append(newPoint) #Append into list else: self.log.warning("Found blank lines in the csv, skipping it") csvFile.close() except: self.log.error("The content of the polygon csv is invalid") status= -1 return pointsList, status