Created
February 19, 2011 17:30
-
-
Save lifeeth/835208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import math | |
| import csv | |
| from openpyxl.reader.excel import load_workbook | |
| files = os.listdir('files/') | |
| for filename in files: | |
| filename = filename.split(".")[0] | |
| wb2 = load_workbook("files/"+filename+'.xlsx') | |
| output_writer = csv.writer(open("csvfiles/"+filename+'.csv','wb')) | |
| sheet = wb2.get_sheet_by_name(name = 'Sheet1') | |
| highest_row = sheet.get_highest_row() | |
| D=[] | |
| for i in range(highest_row): | |
| if not sheet.cell(row=i,column = 3): | |
| break | |
| D.append([sheet.cell(row=i,column = 3).value,sheet.cell(row=i,column =4).value]) | |
| step = math.pow(2.0,1.0/8) | |
| i = 4+step | |
| readfrom = 0 | |
| while i < 16386: | |
| y = 0 | |
| count = 0 | |
| while readfrom < len(D): | |
| if D[readfrom][0] < i: | |
| if D[readfrom][0] > i - step: | |
| y = y + D[readfrom][1] | |
| count = count+1 | |
| readfrom = readfrom + 1 | |
| else: | |
| break | |
| output_writer.writerow([i-step/2,y/count]) | |
| i = i + step | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment