I have
---
title: ""
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
```
\begin{tabular}[t]{#{}ll}
***Why*** & one\\
*does* & two\\
**this happen** & three \\
\end{tabular}
However Why does this happen appear in normal font and not italics/bold.
How can I change this?
this did the job
---
title: ""
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
```
\begin{tabular}[t]{#{}ll}
\textbf{Why} & one\\
\textbf{does} & two\\
\textbf{This happen} & three \\
\end{tabular}
Related
I have a dataframe where i want to add an binary column indicator. The below is for shop e. I need to create many such flag columns depending on what the letter is e.g. shop e, a, b, c, d...
df = df[df['ope_p_e'] == 0]
df["shop_e_flag"] = np.where(((df['reven_a']==0)
& (df['reven_b']==0)
& (df['reven_c']==0)
& (df['reven_d']==0)
& (df['reven_f']==0))
& (df['reven_e'] >0) , 1, 0)
for shop b i need to do :
df = df[df['ope_p_b'] == 0]
df["shop_b_flag"] = np.where(((df['reven_a']==0)
& (df['reven_e']==0)
& (df['reven_c']==0)
& (df['reven_d']==0)
& (df['reven_f']==0))
& (df['reven_b'] >0) , 1, 0)
so each time the pre filter changes according to flag column i am creating. How can i automate the above..otherwise i end up writing the same code for each shop! Is there an easier way to automate this where i can 'select' the shop name i want flag for and it creates the above logic?
i tried the following but it takes so long:
def create_col(df,shop='a'):
all_shops = ['a','b','c','d','e']
other_shops = [x for x in all_shops if x not in shop]
df = df[df[f'ope_p_{shop}'] == 0]
df[f"shop_{shop}_flag"] = np.where(((df[f'reven_{other_shops[0]}']==0)
& (df[f'reven_{other_shops[1]}']==0)
& (df[f'reven_{other_shops[2]}']==0)
& (df[f'reven_{other_shops[3]}']==0)
& (df[f'reven_{other_shops[4]}']==0))
& (df[f'reven_{shop}'] >0) , 1, 0)
return df
How can i optimize this?
Hi Guys im trying to excute a cmd line from VBA but it keeps giveing me errors like "c:\program" is not reconised. ive been stuck here for hours adding Chr(34) and other things but still no luck.
here is my code
Path = """C:\Users\Phill\Desktop\Mortgage Illustration 211206142739.pdf"""
scommand = """C:\Program Files (x86)\A-PDF Data Extractor\PRCMD.exe""" & _
Path
Shell "cmd.exe /k " & scommand, vbNormalFocus
Maybe something like this:
Dim exe, pth
exe = "C:\Program Files (x86)\A-PDF Data Extractor\PRCMD.exe"
pth = "C:\Users\Phill\Desktop\Mortgage Illustration 211206142739.pdf"
Shell "cmd.exe /k """"" & exe & """ """ & pth & """""", vbNormalFocus
EDIT: fixed - the whole command (exe plus path) also needs to be quoted...
When I'm doing " sum(ev3.MT_BRUT) as Ecart " I lost all rows with ev3.MT_BRUT=.
My code is :
RECSET2.Open " select dossier.NO_POLICE, ev1.D_EFFET, ev1.ID_FAMILLE_PORTEF, ev1.ID_PORTEFEUILLE, gr.LB_COURT_GR_EVT, pers1.S_PRENOM||' '||pers1.S_NOM as Collaborateur, proto.CD_PROTOCOLE, ev1.ID_FAMILLE_PORTEF,comm.L_COMMENT_DOSSIER," & _
" dossier.UI_CREATION, ev1.LP_STATUT_EVT, sum(ev3.MT_BRUT) as Ecart, ev1.MT_BRUT, tiers2.CD_TIERS as Tmandataire, pers3.S_RAISONSOC as Mandataire,tiers1.CD_TIERS as Tdepositaire, pers2.S_RAISONSOC as Depositaire, ev1.IS_EVENEMENT from DB_DOSSIER dossier left join DB_EVENEMENT ev1 " & _
" on dossier.IS_DOSSIER = ev1.IS_DOSSIER left join DB_EVENEMENT ev2 on ev1.IS_EVENEMENT=ev2.IS_EVENEMENT_PERE left join DR_LIEN_EVT drevl on ev2.IS_EVENEMENT=drevl.IS_EVENEMENT left join DB_EVENEMENT ev3 on drevl.IS_EVT_LIE=ev3.IS_EVENEMENT left join DP_CLASSE_EVT cl on ev1.IS_CLASSE_EVT=cl.IS_CLASSE_EVT " & _
" left join DP_GROUPE_EVT gr on cl.IS_GR_EVT=gr.IS_GR_EVT left join DB_COMMENT_DOSSIER comm on dossier.IS_DOSSIER=comm.IS_DOSSIER left join DR_COLLABORATEUR_PROTOCOLE collabproto on dossier.IS_PROTOCOLE=collabproto.IS_PROTOCOLE left join DB_COLLABORATEUR collab on collabproto.IS_COLLABORATEUR=collab.IS_COLLABORATEUR " & _
" left join DB_PERSONNE pers1 on collab.IS_PERSONNE=pers1.IS_PERSONNE left join DB_PROTOCOLE proto on dossier.IS_PROTOCOLE=proto.IS_PROTOCOLE left join DB_PORTEFEUILLE portef1 on ev1.ID_FAMILLE_PORTEF=portef1.ID_FAMILLE_PORTEF and ev1.ID_PORTEFEUILLE=portef1.ID_PORTEFEUILLE left join DB_TIERS tiers1 on tiers1.IS_TIERS=portef1.IS_TIERS_DEPOSITAIRE " & _
" left join DB_PERSONNE pers2 on tiers1.IS_PERSONNE=pers2.IS_PERSONNE left join DB_TIERS tiers2 on tiers2.IS_TIERS=portef1.IS_TIERS_GESTIONNAIRE left join DB_PERSONNE pers3 on tiers2.IS_PERSONNE=pers3.IS_PERSONNE " & _
" where dossier.CD_DOSSIER in ('COROP','COROC') and dossier.LP_ETAT_DOSS not in ('CLOSE','ANNUL','A30') and ev1.D_EFFET>='" & Ma_date & "' and ev1.IS_EVENEMENT_PERE is null and drevl.LP_LIEN_EVT in ('COROP','COROC') " & _
" group by dossier.NO_POLICE, ev1.D_EFFET, ev1.ID_FAMILLE_PORTEF, ev1.ID_PORTEFEUILLE, gr.LB_COURT_GR_EVT, pers1.S_PRENOM, pers1.S_NOM, proto.CD_PROTOCOLE, ev1.ID_FAMILLE_PORTEF,comm.L_COMMENT_DOSSIER," & _
" dossier.UI_CREATION, ev1.LP_STATUT_EVT, ev1.MT_BRUT, tiers2.CD_TIERS, pers3.S_RAISONSOC,tiers1.CD_TIERS, pers2.S_RAISONSOC, ev1.IS_EVENEMENT ", cnn_Pegase, adOpenDynamic, adLockBatchOptimistic
I'm wondering if my export is working for the "Ecart" missing values :
xlRow = Range("Chapeau").Row + 1 + xlRow
If Not RECSET2.EOF Then
Do While Not RECSET2.EOF
ActiveSheet.Cells(xlRow, Range("Colonne_1").Column).Value = RECSET2("LB_COURT_GR_EVT").Value
ActiveSheet.Cells(xlRow, Range("Colonne_2").Column).Value = RECSET2("Collaborateur").Value
ActiveSheet.Cells(xlRow, Range("Colonne_3").Column).Value = RECSET2("CD_PROTOCOLE").Value
ActiveSheet.Cells(xlRow, Range("Colonne_4").Column).Value = RECSET2("NO_POLICE").Value
RECSET2.MoveNext
xlRow = xlRow + 1
Loop
Else
ActiveSheet.Cells(xlRow, Range("Colonne_1").Column).Value = ""
ActiveSheet.Cells(xlRow, Range("Colonne_2").Column).Value = ""
ActiveSheet.Cells(xlRow, Range("Colonne_3").Column).Value = ""
ActiveSheet.Cells(xlRow, Range("Colonne_4").Column).Value = ""
*****************************************************************
End If
RECSET2.Close
Call DECONNEXION_PEGASE
Thank your for help !
Our team uses python to log some user access activities.
We created both local logging and google cloud logging (Stackdriver) to capture the exceptions.
Local log shows 5 entries
Our team's Stackdriver log shows 2 entries
I also tested with my own google cloud stackdriver log. It shows 5 tries.
Here is the code:
local_logger = local_logging.getLogger(__name__)
local_logger.setLevel(local_logging.INFO)
handler = local_logging.FileHandler('Azure-user-access-audit-log.log')
handler.setLevel(local_logging.CRITICAL)
local_logging.Formatter.converter = time.gmtime
formatter = local_logging.Formatter('%(asctime)s | %(levelname)s | %(message)s')
handler.setFormatter(formatter)
local_logger.addHandler(handler)
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "my-credential.json"
logging_client = cloud_logging.Client()
log_name = 'Azure-user-access-audit-log'
cloud_logger = logging_client.logger(log_name)
............
if item['subcriptionType'] == 'Hacker':
user_log = str(item['cloudName'] + " - " + item['tenantId'] + " | " +
item['subcriptionType'] + " " + item['principalName'] + " has access to " + item['subscriptionName'] + " as "
+ item['roleDefinitionName'])
local_logger.critical(user_log)
# The data to log to Google Cloud
google_log_message = item['subcriptionType'] + " " + item['principalName'] + " has access to " + item['subscriptionName'] + " as " + item['roleDefinitionName']
google_log_severity = 'CRITICAL'
google_log_insert_id = item['cloudName'] + " - " + item['tenantId']
print(google_log_message)
print(google_log_severity)
print(google_log_insert_id)
# Writes the log entry
# cloud_logger.log_text(str(google_log_message), severity = str(google_log_severity), insert_id = str(google_log_insert_id))
# # cloud_logger.log_struct({
# # 'subcriptionType': item['subcriptionType'],
# # 'principalName': item['principalName'],
# # 'subscriptionName': item['subscriptionName']
# # }, severity = str(google_log_severity), insert_id = str(google_log_insert_id))
cloud_logger.log_text(str(google_log_message))
If i added the commented-out piece of code for severity and insert-id, nothing would go through. I'm pretty sure that syntax was good.
Please help me out.
Thank y'all so much
You are using insertId incorrectly. The Stackdriver Logging API considers all log entries in the same project, with the same timestamp, and with the same insertId to be duplicates which can be removed. All of your insertId values seem to be the same. The only reason you're seeing two entries in Stackdriver Logging and not one is that the two entries that do make it through have different timestamps.
You can just omit the insertId field. The API will set one automatically.
I am trying to automate some repetitive work for getting results from a website,
this link Drugs.com, checks for interaction between two medicines.
I must take the text of the two medicines from the Excel sheet and enter them on the website to check the interaction between them.
Here is a sample of my Excel sheet:
column(A) Column(B)
(A1)candesartan benazepril
(A2)eprosartan captopril
(A3)irbesartan enalapril
When I press 'Check For Interaction' the result of the next page must be extracted and return one of tree interactions:
-major
-moderate
-minor
This must then write the result to column(c)
I am a beginner at autoit but I can do some scripting albeit with a lot of bugs.
I will appreciate it if someone can correct/assist me with the bugs in my code. I will also appreciate it if someone can help me with the correct keywords so that I can Google for examples and solutions.
Thanks all.
#include <Excel.au3>
#include <IE.au3>
#include <File.au3>
Local $sWorkbook = "C:\Users\Aligaaly\Desktop\autoit\test\drugs.xlsx"
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
$oWorkbook = _Excel_BookAttach($sWorkbook)
GLOBAL $oIE = _IECreate("https://www.drugs.com/drug_interactions.php")
Local $oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
$text_form1 = _IEGetObjById($oIE, "livesearch-interaction")
If StringLower($oInput.classname) == "input-button search-button" and _IEFormElementGetValue($oInput) Then ; it is an input
Global $oInput_btn = $oInput
EndIf
Next
WinActivate("[CLASS:XLMAIN]", "")
For $i = 1 To 5
Global $sResulta = _Excel_RangeRead($oWorkbook, Default, 'A' & $i & ':A' & $i,1 )
For $y = 1 To 5
Global $sResultb = _Excel_RangeRead($oWorkbook, Default, 'B' & $y & ':B' & $y,1 )
WinActivate("[CLASS:IEFrame]", "")
_IEFormElementSetValue($text_form1, $sResulta )
_IEAction ($oInput_btn, "click")
sleep(5000)
_IEFormElementSetValue($text_form1, $sResultb )
_IEAction ($oInput_btn, "click")
sleep(5000)
For $oInput In $oInputs
If StringLower($oInput.value) == "check for interactions" Then
Global $check_btn = $oInput
EndIf
Next
_IEAction ($check_btn, "click")
sleep(5000)
$oButtonsa = _IETagnameGetCollection($oIE, "span")
For $oButtonn in $oButtonsa
If $oButtonn.classname == "status-category status-category-major" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "major","C" & $y)
ElseIf $oButtonn.classname == "status-category status-category-moderate" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "moderate","C" & $y)
ElseIf $oButtonn.classname == "status-category status-category-minor" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "minor","C" & $y)
EndIf
ExitLoop
Next
Next
Next
i have updated the code with my final touches
i think this code is now complete the steps i have write down above
but i have an error when the script finish the first iteration
The problem is in _IEFormElementSetValue function.
Probably,
$text_form1 = _IEGetObjById($oIE, "livesearch-interaction")
can't find any object.
For debug it you can insert this code before _IEFormElementSetValue:
ConsoleWrite("isObject:" & isObj($text_form1) & #CRLF)
Update: I found 3 problems.
1) You didn't return to search page after end of iteration and the input object can't be found;
2) You must get Input and Button object on the start of each iteration;
3) Exitloop must be on each If ... esleif section.
Try this code:
#include <Excel.au3>
#include <IE.au3>
#include <File.au3>
Local $sWorkbook = "C:\Users\Aligaaly\Desktop\autoit\test\drugs.xlsx"
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
$oWorkbook = _Excel_BookAttach($sWorkbook)
GLOBAL $oIE = _IECreate("https://www.drugs.com/drug_interactions.php")
Local $oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
$text_form1 = _IEGetObjById($oIE, "livesearch-interaction")
If StringLower($oInput.classname) == "input-button search-button" and _IEFormElementGetValue($oInput) Then ; it is an input
Global $oInput_btn = $oInput
EndIf
Next
WinActivate("[CLASS:XLMAIN]", "")
For $i = 1 To 5
Global $sResulta = _Excel_RangeRead($oWorkbook, Default, 'A' & $i & ':A' & $i,1 )
For $y = 1 To 5
Global $sResultb = _Excel_RangeRead($oWorkbook, Default, 'B' & $y & ':B' & $y,1 )
$oInputs = _IETagNameGetCollection($oIE, "input")
For $oInput In $oInputs
$text_form1 = _IEGetObjById($oIE, "livesearch-interaction")
If StringLower($oInput.classname) == "input-button search-button" and _IEFormElementGetValue($oInput) Then ; it is an input
$oInput_btn = $oInput
EndIf
Next
WinActivate("[CLASS:IEFrame]", "")
_IEFormElementSetValue($text_form1, $sResulta )
_IEAction ($oInput_btn, "click")
sleep(5000)
_IEFormElementSetValue($text_form1, $sResultb )
_IEAction ($oInput_btn, "click")
sleep(5000)
For $oInput In $oInputs
If StringLower($oInput.value) == "check for interactions" Then
Global $check_btn = $oInput
EndIf
Next
_IEAction ($check_btn, "click")
sleep(5000)
$oButtonsa = _IETagnameGetCollection($oIE, "span")
For $oButtonn in $oButtonsa
If $oButtonn.classname == "status-category status-category-major" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "major","C" & $y)
ExitLoop
ElseIf $oButtonn.classname == "status-category status-category-moderate" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "moderate","C" & $y)
ExitLoop
ElseIf $oButtonn.classname == "status-category status-category-minor" Then
WinActivate("[CLASS:XLMAIN]", "")
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "minor","C" & $y)
ExitLoop
EndIf
Next
_IENavigate($oIE, "https://www.drugs.com/drug_interactions.php?action=new_list")
Next
Next