Forum Discussion
Prompts to Power BI using Python scripts
- 7 years ago
Anonymous ,
Please import the csv to power bi at first. Then implement the python script. The script works well on my side.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous ,
I have made a test on my side, but your python script works well on my side. I have formatted your code as below:
# 'dataset' holds the input data for this script
import pandas as pd
v1 = dataset['Latest Packaged Version'].fillna('').tolist()
v2 = dataset['Version'].fillna('').tolist()
def converter_list(version_list):
v12 = list()
for i in version_list:
temp = i.replace(".", "")
temp1 = ""
zero_flag = 0
for j in reversed(range(0, len(temp))):
if(temp[j] == '0'):
zero_flag = 1
temp1 = temp[j]
else:
break
if(zero_flag):
temp1 = temp
if(temp1 == ""):
temp1 = "0"
v12.append(int(temp1))
return (v12)
def compare_list(list1, list2):
temp_list = list()
for i, j in zip(list1, list2):
if i >= j:
temp_list.append(False)
else:
temp_list.append(True)
return temp_list
v1_int = converter_list(v1)
v2_int = converter_list(v2)
version_check_list = compare_list(v1_int, v2_int)
dataset['res'] = pd.Series(version_check_list)
So if your issue still persists, I think it's related to your data source. Please check if the value in [Version] or [Latest Packaged Version] are text type after imported in power bi.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot for the prompt revert. I wasted so much time to figure this out but all went in vain. I have made changes to the script. Could you please help me with the new script? i would be very thankful to you.
Also, when I tried executing your code it gave me the result attached with this message.
import pandas as pd
v1 = dataset['Latest Packaged Version'].fillna('').tolist()
v2 = dataset['Version'].fillna('').tolist()
def change_string_to_ascii(v12):
fin_list = []
for i in v12:
if(i.isdigit()):
fin_list.append(i)
else:
#print(i)
fin_list.append((ord(i))
#fin_str = "".join(fin_list)
return fin_list
def compare_list(list1, list2):
result_list = []
for i,j in zip(list1, list2):
if (i == "" or j == ""):
if(i == ""):
result_list.append("Upgraded")
else:
result_list.append("Not Upgraded")
continue
if(len(i) > len(j)):
result_list.append("Not Upgraded")
continue
elif(len(i)< len(j)):
result_list.append("Upgraded")
continue
else:
i_arr = i.split(".")
j_arr = j.split(".")
i_arr_dl = change_string_to_ascii(i_arr)
j_arr_dl = change_string_to_ascii(j_arr)
count = 0
for i_val, j_val in zip(i_arr_dl, j_arr_dl):
count+=1
if(i_val > j_val):
result_list.append("Not Upgraded")
break
elif(i_val == j_val):
#print(count, len(i_arr))
if(count == len(i_arr)):
#print("added")
result_list.append("Upgraded")
else:
continue
elif(i_val < j_val):
result_list.append("Upgraded")
break
return result_list
version_check_list = compare_list(v1, v2)
dataset['res'] = pd.Series(version_check_list)
- v-yuta-msft7 years agoCommunity Support
Anonymous ,
What's the issue? Could you clarify more details about the issue or requirement and share some sample data/sample file?
Regards,
Jimmy Tao
- Anonymous7 years agoNot applicable
Hi Jimmy,
I am still not able to run the file. I am attaching the error snap along with some sample data for you. Thank you again.
Sample Data:
_ResourceGuid DisplayName SoftwareProduct InstallDate Version Latest Packaged Version 19b65d1a-54ab-46ca-8fba-0003dd6f492f Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 5/19/2019 0:00 16.0.10730.20264 16.0.8431.2250 19b65d1a-54ab-46ca-8fba-0003dd6f492f 7-Zip 19.00 (x64 edition) 7-Zip 6/10/2019 0:00 19.00.00.0 18.06.00.0 19b65d1a-54ab-46ca-8fba-0003dd6f492f 7-Zip 19.00 (x64 edition) 7-Zip 6/10/2019 0:00 19.00.00.0 18.06.00.0 949b9d33-8922-4392-a808-0004281523c8 Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 3/11/2019 0:00 3.2.1.51 3.2.1.51 949b9d33-8922-4392-a808-0004281523c8 Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 3/11/2019 0:00 3.2.1.51 3.2.1.51 949b9d33-8922-4392-a808-0004281523c8 Google Earth Pro Google Earth Pro 3/29/2019 0:00 7.3.2.5776 7.1.5.1557 949b9d33-8922-4392-a808-0004281523c8 Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 5/6/2019 0:00 16.0.10730.20334 16.0.8431.2250 949b9d33-8922-4392-a808-0004281523c8 Notepad++ (64-bit x64) Notepad++ 12/12/2018 0:00 7.5.6 null 949b9d33-8922-4392-a808-0004281523c8 SnapComms App SnapComms App 17 4/1/2019 0:00 17.12.1456 17.12.1456 949b9d33-8922-4392-a808-0004281523c8 SteelCentral Aternity Agent Aternity Agent 9.2 5/10/2019 0:00 9.2.6.41 9.2.6.41 9dd8b833-fdd2-44b6-8cff-000477014629 Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 5/26/2019 0:00 16.0.10730.20334 16.0.8431.2250 9dd8b833-fdd2-44b6-8cff-000477014629 SteelCentral Aternity Agent Aternity Agent 9.2 5/15/2019 0:00 9.2.6.41 9.2.6.41 9dd8b833-fdd2-44b6-8cff-000477014629 VMware Horizon Client VMware Horizon Client 4 2/5/2019 0:00 4.7.0.11074 4.7.0.11074 3707a2c7-a5a4-4e59-83a5-0005a44b344f Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 11/1/2018 0:00 3.2.1.51 3.2.1.51 3707a2c7-a5a4-4e59-83a5-0005a44b344f Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 11/1/2018 0:00 3.2.1.51 3.2.1.51 3707a2c7-a5a4-4e59-83a5-0005a44b344f Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 5/16/2019 0:00 16.0.10730.20334 16.0.8431.2250 3707a2c7-a5a4-4e59-83a5-0005a44b344f SteelCentral Aternity Agent Aternity Agent 9.2 5/3/2019 0:00 9.2.6.41 9.2.6.41 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Aternity Agent Aternity Agent 9.1 4/20/2018 0:00 9.1.7.44 9.1.7.44 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Microsoft Office 365 ProPlus - fr-fr Microsoft Office 365 ProPlus 2016 3/18/2019 0:00 16.0.8431.2329 16.0.8431.2250 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 VMware Horizon Client VMware Horizon Client 4 4/24/2018 0:00 4.5.0.8090 4.7.0.11074 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Microsoft OneDrive Microsoft OneDrive 19 4/17/2019 0:00 19.043.0304.0007 19.033.0218.0011 bca403f8-6055-4e95-9d40-0006b08299c4 7-Zip 19.00 (x64 edition) 7-Zip 4/24/2019 0:00 19.00.00.0 18.06.00.0 bca403f8-6055-4e95-9d40-0006b08299c4 7-Zip 19.00 (x64 edition) 7-Zip 4/24/2019 0:00 19.00.00.0 18.06.00.0 bca403f8-6055-4e95-9d40-0006b08299c4 Microsoft Office 365 ProPlus - pl-pl Microsoft Office 365 ProPlus 2016 5/5/2017 0:00 16.0.6965.2105 16.0.8431.2250 bca403f8-6055-4e95-9d40-0006b08299c4 Microsoft Visio Professional 2016 - pl-pl Microsoft Visio Professional 2016 5/5/2017 0:00 16.0.6965.2105 16.0.7167.2040 bca403f8-6055-4e95-9d40-0006b08299c4 Microsoft Visio Professional 2016 - pl-pl Microsoft Visio Professional 2016 5/5/2017 0:00 16.0.6965.2105 16.0.7167.2040 bca403f8-6055-4e95-9d40-0006b08299c4 Microsoft OneDrive Microsoft OneDrive 19 6/16/2019 0:00 19.086.0502.0006 19.033.0218.0011 a3c60af5-aa37-40fd-8332-0006e63c2215 ALM v4 ALM 4.5 4/23/2019 0:00 4.5.0.9 4.5.0.9 a3c60af5-aa37-40fd-8332-0006e63c2215 SnapComms App SnapComms App 17 7/30/2018 0:00 17.12.1456 17.12.1456 a3c60af5-aa37-40fd-8332-0006e63c2215 Microsoft OneDrive Microsoft OneDrive 19 6/7/2019 0:00 19.086.0502.0006 19.033.0218.0011 a3c5e533-8eb0-41fc-a192-000779929fcd Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 11/29/2018 0:00 3.2.1.51 3.2.1.51 a3c5e533-8eb0-41fc-a192-000779929fcd Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 11/29/2018 0:00 3.2.1.51 3.2.1.51 a3c5e533-8eb0-41fc-a192-000779929fcd 7-Zip 19.00 (x64 edition) 7-Zip 3/22/2019 0:00 19.00.00.0 18.06.00.0 a3c5e533-8eb0-41fc-a192-000779929fcd 7-Zip 19.00 (x64 edition) 7-Zip 3/22/2019 0:00 19.00.00.0 18.06.00.0 a3c5e533-8eb0-41fc-a192-000779929fcd Microsoft Office 365 ProPlus - fr-fr Microsoft Office 365 ProPlus 2016 11/30/2018 0:00 16.0.9126.2315 16.0.8431.2250 a3c5e533-8eb0-41fc-a192-000779929fcd SnapComms App SnapComms App 17 12/3/2018 0:00 17.12.1456 17.12.1456 a3c5e533-8eb0-41fc-a192-000779929fcd VMware Horizon Client VMware Horizon Client 4 11/29/2018 0:00 4.8.1.2179 4.7.0.11074 a3c5e533-8eb0-41fc-a192-000779929fcd Microsoft OneDrive Microsoft OneDrive 19 4/17/2019 0:00 19.043.0304.0007 19.033.0218.0011 48d43e86-835d-4769-b792-00078dacc5f1 Google Earth Pro Google Earth Pro 3/19/2019 0:00 7.3.2.5776 7.1.5.1557 48d43e86-835d-4769-b792-00078dacc5f1 Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 5/12/2019 0:00 16.0.10730.20334 16.0.8431.2250 48d43e86-835d-4769-b792-00078dacc5f1 Snagit 2018 Snagit 2018 7/24/2018 0:00 18.2.1 18.2.1.1590 48d43e86-835d-4769-b792-00078dacc5f1 Microsoft OneDrive Microsoft OneDrive 19 6/17/2019 0:00 19.086.0502.0006 19.033.0218.0011 061a0b6c-9ecc-4f18-ac0f-000971bb94ad Aternity Agent Aternity Agent 9.1 12/4/2017 0:00 9.1.7.44 9.1.7.44 061a0b6c-9ecc-4f18-ac0f-000971bb94ad Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/12/2018 0:00 3.2.1.51 3.2.1.51 061a0b6c-9ecc-4f18-ac0f-000971bb94ad Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/12/2018 0:00 3.2.1.51 3.2.1.51 061a0b6c-9ecc-4f18-ac0f-000971bb94ad McAfee Agent McAfee Agent 5 8/2/2017 0:00 5.0.4.470 5.0.6.220 061a0b6c-9ecc-4f18-ac0f-000971bb94ad Microsoft Office 365 ProPlus - en-us Microsoft Office 365 ProPlus 2016 3/26/2019 0:00 16.0.10730.20304 16.0.8431.2250 061a0b6c-9ecc-4f18-ac0f-000971bb94ad SnapComms App SnapComms App 17 1/10/2018 0:00 17.12.1456 17.12.1456 949d0c91-2eb7-4345-96d5-000a48f8fa67 Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/12/2018 0:00 3.2.1.51 3.2.1.51 949d0c91-2eb7-4345-96d5-000a48f8fa67 Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/12/2018 0:00 3.2.1.51 3.2.1.51 8970e2b2-26d8-4566-8bb7-000a8989dd10 7-Zip 19.00 (x64 edition) 7-Zip 4/2/2019 0:00 19.00.00.0 18.06.00.0 8970e2b2-26d8-4566-8bb7-000a8989dd10 7-Zip 19.00 (x64 edition) 7-Zip 4/2/2019 0:00 19.00.00.0 18.06.00.0 8970e2b2-26d8-4566-8bb7-000a8989dd10 VMware Horizon Client VMware Horizon Client 4 3/8/2019 0:00 4.10.0.4272 4.7.0.11074 8970e2b2-26d8-4566-8bb7-000a8989dd10 Microsoft OneDrive Microsoft OneDrive 19 6/11/2019 0:00 19.086.0502.0006 19.033.0218.0011 c22e43ed-c62b-4bc1-a1f2-000c957b9e3e Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/14/2018 0:00 3.2.1.51 3.2.1.51 c22e43ed-c62b-4bc1-a1f2-000c957b9e3e Cb Defense Sensor 64-bit Carbon Black Defense Sensor 3 9/14/2018 0:00 3.2.1.51 3.2.1.51 c22e43ed-c62b-4bc1-a1f2-000c957b9e3e SteelCentral Aternity Agent Aternity Agent 9.2 5/10/2019 0:00 9.2.6.41 9.2.6.41 19b65d1a-54ab-46ca-8fba-0003dd6f492f Cisco AnyConnect Secure Mobility Client Cisco AnyConnect Secure Mobility Client 4 5/19/2019 0:00 4.3.05017 4.3.05017 19b65d1a-54ab-46ca-8fba-0003dd6f492f Cisco Jabber Cisco Jabber 5/19/2019 0:00 12.1.1.19866 12.5.1.27406 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix Workspace 1812 Citrix Workspace 5/19/2019 0:00 18.12.0.12 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix WorkSpace Browser Citrix Workspace 5/19/2019 0:00 18.12.0.10 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix Workspace Inside Citrix Workspace 5/19/2019 0:00 18.12.0.65534 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix Workspace(Aero) Citrix Workspace 5/19/2019 0:00 18.12.0.12 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix Workspace(SSON) Citrix Workspace 5/19/2019 0:00 18.12.0.12 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Citrix Workspace(USB) Citrix Workspace 5/19/2019 0:00 18.12.0.12 null 19b65d1a-54ab-46ca-8fba-0003dd6f492f Veritas Enterprise Vault Outlook Add-in (x64) 12.2.1.1485 Veritas Enterprise Vault Outlook Add-in 12 5/19/2019 0:00 12.2.5581 12.2.9718 19b65d1a-54ab-46ca-8fba-0003dd6f492f Veritas Enterprise Vault Outlook Add-in (x64) 12.2.1.1485 Veritas Enterprise Vault Outlook Add-in 12 5/19/2019 0:00 12.2.5581 12.2.9718 19b65d1a-54ab-46ca-8fba-0003dd6f492f Java 8 Update 202 Java(TM) 8 6/10/2019 0:00 8.0.2020.8 null 949b9d33-8922-4392-a808-0004281523c8 Citrix WorkSpace Browser Citrix Workspace 12/12/2018 0:00 18.9.0.19515 null 949b9d33-8922-4392-a808-0004281523c8 Citrix Workspace Inside Citrix Workspace 12/12/2018 0:00 18.9.0.65534 null 949b9d33-8922-4392-a808-0004281523c8 Citrix Workspace(DV) Citrix Workspace 12/12/2018 0:00 18.9.0.19526 null 949b9d33-8922-4392-a808-0004281523c8 Citrix Workspace(USB) Citrix Workspace 12/12/2018 0:00 18.9.0.19526 null 949b9d33-8922-4392-a808-0004281523c8 Google Chrome Google Chrome 5/22/2019 0:00 74.0.3729.169 73.0.3683.86 949b9d33-8922-4392-a808-0004281523c8 Adobe Acrobat DC Adobe Acrobat DC 19 6/13/2019 0:00 19.012.20035 null 9dd8b833-fdd2-44b6-8cff-000477014629 Cisco AnyConnect Secure Mobility Client Cisco AnyConnect Secure Mobility Client 4 2/5/2019 0:00 4.3.05017 4.3.05017 9dd8b833-fdd2-44b6-8cff-000477014629 Google Chrome Google Chrome 2/5/2019 0:00 74.0.3729.169 73.0.3683.86 9dd8b833-fdd2-44b6-8cff-000477014629 Microsoft Teams Microsoft Teams 1 5/28/2019 0:00 1.2.00.13765 1.2.00.8864 9dd8b833-fdd2-44b6-8cff-000477014629 Java 8 Update 202 Java(TM) 8 2/23/2019 0:00 8.0.2020.8 null 3707a2c7-a5a4-4e59-83a5-0005a44b344f Cisco AnyConnect Secure Mobility Client Cisco AnyConnect Secure Mobility Client 4 11/19/2018 0:00 4.5.05030 4.3.05017 3707a2c7-a5a4-4e59-83a5-0005a44b344f Google Chrome Google Chrome 5/28/2019 0:00 74.0.3729.169 73.0.3683.86 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Cisco AnyConnect Secure Mobility Client Cisco AnyConnect Secure Mobility Client 4 4/13/2018 0:00 4.3.05017 4.3.05017 c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Java 8 Update 202 Java(TM) 8 2/25/2019 0:00 8.0.2020.8 null c996c00f-63ce-4c6d-b0ba-0005f64af7c4 Adobe Acrobat Reader DC Adobe Acrobat Reader DC 19 4/29/2019 0:00 19.010.20099 19.010.20098 bca403f8-6055-4e95-9d40-0006b08299c4 Cisco AnyConnect Secure Mobility Client Cisco AnyConnect Secure Mobility Client 4 4/21/2017 0:00 4.3.05017 4.3.05017 bca403f8-6055-4e95-9d40-0006b08299c4 Cisco Jabber Cisco Jabber 4/16/2019 0:00 12.1.1.19866 12.5.1.27406 bca403f8-6055-4e95-9d40-0006b08299c4 Google Chrome Google Chrome 5/29/2019 0:00 74.0.3729.169 73.0.3683.86 bca403f8-6055-4e95-9d40-0006b08299c4 Microsoft Office SharePoint Designer MUI (English) 2007 Microsoft SharePoint Designer 2007 6/26/2017 0:00 12.0.6612.1000 null bca403f8-6055-4e95-9d40-0006b08299c4 Veritas Enterprise Vault Outlook Add-in (x64) 12.1.1.1451 Veritas Enterprise Vault Outlook Add-in 12 8/31/2017 0:00 12.1.5547 12.2.9718 bca403f8-6055-4e95-9d40-0006b08299c4 Veritas Enterprise Vault Outlook Add-in (x64) 12.1.1.1451 Veritas Enterprise Vault Outlook Add-in 12 8/31/2017 0:00 12.1.5547 12.2.9718 a3c60af5-aa37-40fd-8332-0006e63c2215 Adobe Acrobat Reader DC MUI Adobe Acrobat Reader DC 19 5/1/2019 0:00 19.010.20099 19.010.20098 a3c60af5-aa37-40fd-8332-0006e63c2215 Dell Display Manager Dell Display Manager 4/23/2019 0:00 a3c60af5-aa37-40fd-8332-0006e63c2215 Google Chrome Google Chrome 5/22/2019 0:00 74.0.3729.169 73.0.3683.86 a3c60af5-aa37-40fd-8332-0006e63c2215 Java 8 Update 202 Java(TM) 8 2/25/2019 0:00 8.0.2020.8 null a3c60af5-aa37-40fd-8332-0006e63c2215 Passcode Passcode 2.0.0 11/10/2017 0:00 2.0.1.0 2.0.1.0 a3c60af5-aa37-40fd-8332-0006e63c2215 Zoom Zoom 4 4/23/2019 0:00 4.1 4.1.34583 a3c5e533-8eb0-41fc-a192-000779929fcd Cisco Jabber Cisco Jabber 3/4/2019 0:00 12.1.1.19866 12.5.1.27406 a3c5e533-8eb0-41fc-a192-000779929fcd Tableau Reader 10.3 (10300.17.0728.2252) Tableau Reader 10 11/29/2018 0:00 10.3.781 10.5.314 a3c5e533-8eb0-41fc-a192-000779929fcd Tableau Reader 10.3 (10300.17.0728.2252) Tableau Reader 10 11/29/2018 0:00 10.3.781 10.5.314 a3c5e533-8eb0-41fc-a192-000779929fcd Veritas Enterprise Vault Outlook Add-in (x64) 12.2.1.1485 Veritas Enterprise Vault Outlook Add-in 12 11/29/2018 0:00 12.2.5581 12.2.9718 - Anonymous7 years agoNot applicable
Any revret on the above woudl be helpful. Thanks again