Spaces:
Sleeping
Sleeping
Update API.py
Browse files
API.py
CHANGED
|
@@ -141,15 +141,17 @@ def getprjParts(chosenprjname,urlNames=prjnamesURL,urlparts=prjpartsURL):
|
|
| 141 |
global dfNames
|
| 142 |
dfNames = pd.read_csv(url_1)
|
| 143 |
chosenprjname=chosenprjname.replace('"', '')
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
url_2 = urlparts.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 146 |
global dfParts
|
| 147 |
dfParts = pd.read_csv(url_2)
|
| 148 |
dfParts= dfParts.iloc[np.where(dfParts['ProjectId']==int(projectNameID))]
|
| 149 |
parts=dfParts['ProjectPart'].tolist()
|
| 150 |
-
print(parts)
|
| 151 |
-
#Get projectName Id
|
| 152 |
-
|
| 153 |
return parts
|
| 154 |
|
| 155 |
# %%
|
|
@@ -159,13 +161,23 @@ def getprjSections(chosenprjname, chosenpart,urlSection=prjsectionsURL):
|
|
| 159 |
dfSections = pd.read_csv(url_1)
|
| 160 |
chosenprjname=chosenprjname.replace('"', '')
|
| 161 |
chosenpart=chosenpart.replace('"', '')
|
| 162 |
-
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
dfSections=dfSections.iloc[np.where((dfSections['ProjectId']==int(projectId)) & (dfSections['ProjectPartId']==int(projectPartID)) ) ]
|
| 165 |
sections=dfSections['ProjectSection'].tolist()
|
| 166 |
return sections
|
| 167 |
-
|
| 168 |
-
|
| 169 |
##############################################################################
|
| 170 |
def update_df(): #get file from drive
|
| 171 |
url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
|
|
|
|
| 141 |
global dfNames
|
| 142 |
dfNames = pd.read_csv(url_1)
|
| 143 |
chosenprjname=chosenprjname.replace('"', '')
|
| 144 |
+
chosenprjnameList=chosenprjname.split(' ')
|
| 145 |
+
for i, row in dfNames.iterrows():
|
| 146 |
+
prjnameString=dfNames['ProjectName'].loc[i]
|
| 147 |
+
if all(name in prjnameString for name in chosenprjnameList):
|
| 148 |
+
projectNameID=dfNames.iloc[i]['ProjectId']
|
| 149 |
+
# projectNameID=dfNames.iloc[np.where(dfNames['ProjectName'].str.startswith(chosenprjnameList[1]))]['ProjectId'] #ProjectName == chosenprjname
|
| 150 |
url_2 = urlparts.replace('/edit#gid=', '/export?format=csv&gid=')
|
| 151 |
global dfParts
|
| 152 |
dfParts = pd.read_csv(url_2)
|
| 153 |
dfParts= dfParts.iloc[np.where(dfParts['ProjectId']==int(projectNameID))]
|
| 154 |
parts=dfParts['ProjectPart'].tolist()
|
|
|
|
|
|
|
|
|
|
| 155 |
return parts
|
| 156 |
|
| 157 |
# %%
|
|
|
|
| 161 |
dfSections = pd.read_csv(url_1)
|
| 162 |
chosenprjname=chosenprjname.replace('"', '')
|
| 163 |
chosenpart=chosenpart.replace('"', '')
|
| 164 |
+
|
| 165 |
+
chosenprjnameList=chosenprjname.split(' ')
|
| 166 |
+
chosenpartList=chosenpart.split(' ')
|
| 167 |
+
for i, row in dfNames.iterrows():
|
| 168 |
+
prjnameString=dfNames['ProjectName'].loc[i]
|
| 169 |
+
if all(name in prjnameString for name in chosenprjnameList):
|
| 170 |
+
projectId=dfNames.iloc[i]['ProjectId']
|
| 171 |
+
# projectId=dfNames.iloc[np.where(dfNames['ProjectName'].astype(str)==chosenprjname)]['ProjectId'] #ProjectName == chosenprjname
|
| 172 |
+
for i, row in dfParts.iterrows():
|
| 173 |
+
prjpartString=dfParts['ProjectPart'].loc[i]
|
| 174 |
+
if all(part in prjpartString for part in chosenpartList):
|
| 175 |
+
projectPartID=dfParts['ProjectPartId'].loc[i]
|
| 176 |
+
# projectPartID=dfParts.iloc[np.where(dfParts['ProjectPart'].astype(str)==chosenpart)]['ProjectPartId']
|
| 177 |
dfSections=dfSections.iloc[np.where((dfSections['ProjectId']==int(projectId)) & (dfSections['ProjectPartId']==int(projectPartID)) ) ]
|
| 178 |
sections=dfSections['ProjectSection'].tolist()
|
| 179 |
return sections
|
| 180 |
+
|
|
|
|
| 181 |
##############################################################################
|
| 182 |
def update_df(): #get file from drive
|
| 183 |
url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
|