Commit 0723f1a9 by logesh.n

email commit

parents
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (email)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/email.iml" filepath="$PROJECT_DIR$/.idea/email.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
# Sending emails through python
# Step 1) Setting up a gmail account for the development
# Step 2) Setting up a Local SMTP server
# Step 3) Sending a plain text
\ No newline at end of file
import smtplib
import ssl
from readxl import df1
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = "logesh.n@knowledgelens.com" # Enter your address
receiver_email = ["rakeshpvofficial@gmail.com", "rakeshpvuokl@gmail.com"] # Enter receiver address
print("heloo")
print(df1)
print(type(df1))
df2 = str(df1)
print("df2", df2)
print(type(df2))
password = input("Type your password and press enter: ")
message = df2
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password)
for i in range(len(receiver_email)):
server.sendmail(sender_email, receiver_email[i], message)
# importing pandas to read the xlsx file
# df1 stores avg of all columns except timestamp, df2 stores max of all columns
# Pandas dataframe.idxmax() method returns the index of the first occurrence of maximum over the requested axis.
import pandas as pd
# using read_excel function to read excel-file
df = pd.read_excel('D:/sources/task3.xlsx')
# rounding of the columns to two decimal points and getting the average of each of the columns
df1 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].mean(), 2)
print("The average of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df1)
# rounding of the columns to two decimal points and getting the max of each of the columns
df2 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].max(), 2)
print("\nThe Maximum of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df2)
# rounding of the columns to two decimal points and getting the min of each of the columns
df3 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].min(), 2)
print("\nThe Minimum of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df3)
dff = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].idxmax(), 0)
dfff = df["current"].idxmax()
print(dff)
# col = "current"
# max_x = df.loc[df[col].idxmax()]
# print("DS")
# print(max_x)
new = df["Timestamp"][dff]
print(new)
\ No newline at end of file
pandas~=1.5.3
openpyxl~=3.0.10
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment