Skip to content

Instantly share code, notes, and snippets.

@christianplazas-wf
Last active March 14, 2018 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianplazas-wf/67c61b691762c1d95f4a74869e5eb736 to your computer and use it in GitHub Desktop.
Save christianplazas-wf/67c61b691762c1d95f4a74869e5eb736 to your computer and use it in GitHub Desktop.
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