2012-10-12 17 views
2

裏面我使用下面的函數:的Python:如何使用進度我的功能

def LAS2TXTGridClip(inFile,poly,MinPoints=1): 
     sf = shapefile.Reader(poly) #open shpfile 
     sr = sf.shapeRecords() 
     poly_filename, ext = path.splitext(poly) 
     inFile_filename = os.path.splitext(os.path.basename(inFile))[0] 
     for i in xrange(len(sr)): 
      verts = np.array(sr[i].shape.points,float) 
      record = sr[i].record[0] 
      inside_points = [p for p in lasfile.File(inFile,None,'r') if pnpoly(p.x, p.y, verts)] 
      if len(inside_points) >= MinPoints: 
       file_out = open("{0}_{1}_{2}.txt".format(poly_filename, inFile_filename, record), "w") 
       for p in inside_points: 
        file_out.write("%s %s %s %s %s %s %s %s %s %s %s" % (p.x, p.y, p.z, p.intensity,p.return_number,p.number_of_returns,p.scan_direction,p.flightline_edge,p.classification,p.scan_angle,record)+ "\n") 
       file_out.close() 

其中for i in xrange(len(sr)):的功能將過程幾次。 len(sr)約爲50萬,我希望插入一個進度條,以便了解我需要等待的時間(星期五)。我有以下問題:

  1. 這是在Windows操作系統上的Python 27「最好,最簡單」的進度條 64位?
  2. 我發現progressbar module但我有問題使用 easy_install進度條在這一步之後。
  3. 哪裏是插入進度條的最佳位置?
+0

閱讀,http://stackoverflow.com/questions/3160699/python-progress-bar – root

回答

4

您對模塊progressbar有什麼問題?這是非常好的解決方案。

$ cd progressbar-2.2/ 
$ sudo python setup.py install 
...blablabla... 
$ python 
>>> from progressbar import ProgressBar 
>>> pbar = ProgressBar(10) 
>>> for i in range(10): 
...  pbar.update(i+1) 
... 
100% |######################################################################| 
+0

我是誠實的,我必須使用「easy_install的進度」 –

+2

問題只需下載並解壓名爲.tar.gz將'python setup.py install'歸檔並運行到'progressbar-2.2'文件夾中(請參閱答案更新) – defuz

+0

是的,我明白我的問題在哪裏。安裝setup.py之後,我曾嘗試導入帶有錯誤消息的進度條。之後,我關閉,我再次打開python,現在我可以導入進度條模塊 –

相關問題