Guest User

Untitled

a guest
Sep 10th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. f = open(path, 'rU')
  2. csv_reader = csv.reader(f)
  3. #getting x and y scales
  4. line1=csv_reader.next()
  5. self.x = (float(re.split('=',line1[2])[1]), float(re.split('=',line1[3])[1]))
  6. self.y = (float(re.split('=',line1[4])[1]), float(re.split('=',line1[5])[1]))
  7.  
  8. csv_reader.next()
  9. line2 = csv_reader.next()[0].split('\t')
  10. coordinateDict = {} #dict of arrays of values
  11. coordinateLineNum = {} #dict of column num
  12.  
  13. count = 0#count for the column num
  14. for line in line2:
  15. coordinateDict[line] = [] #empty array, but it is an array
  16. coordinateLineNum[line] = count
  17. count += 1
  18. print coordinateDict.__str__()
  19. print coordinateLineNum.__str__()
  20. for line in csv_reader:
  21. #each val from each line
  22. linesplit = line[0].split('\t')
  23. #each key in the map
  24. for key in line2:
  25. try:
  26. coordinateDict[key].append(float(linesplit[coordinateLineNum[key]])) #this means "get the number at this line
  27. #where the map's field would align at"
  28. except ValueError:
  29. print "Value Error occured while trying to read in array! Line: " + coordinateLineNum[key].__str__() + " field: " + key.__str__()
  30. break
Advertisement
Add Comment
Please, Sign In to add comment