Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ExcelSortScript.py
import openpyxl
import pandas as pd
wb = openpyxl.load_workbook('RawCageData.xlsx', data_only=True)
sheet = wb['Sheet1']
print(sheet["A1"].value)
n = input("Please Enter the Total Number of Devices: ")
deviceNum = range(1,n+1)
print deviceNum
x = sheet.max_row
y = sheet.max_column
# columnH = []
# columnF = []
# # def
deviceDict = {} # This makes a new dict
for i in deviceNum:
deviceDict[i] = [] #this makes a new list for a device
for j in range(1, x):
if (sheet.cell(row=j,column = 2).value) == i:
columnH = []
# columnF = []
param1 = "H%s" % str(j)
# param2 = "F%s" % str(j)
#columnH.append(sheet[param1].value)
deviceDict[i].append(sheet[param1].value)
# columnF.append(sheet[param2].value)
#print columnH
print deviceDict[i]
#dataFrameH = pd.DataFrame(columnH, columns = list("a"))
dataFrameH = pd.DataFrame(deviceDict)
print dataFrameH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment