I tried to streamline the standard role of new employees with Python

Hello. I tried to streamline the standard role of new employees, telephone answering, with Python.

It is common for the person to handle the call to not be at your desk. At that time, I would send an e-mail telling me that there was a call, but it is actually troublesome to write a fixed text every time. So I wrote a program to create the text and subject.

What to do this time

Output a txt file like this. The first line is the subject. The text after that is the text.

TELmemo.txt


[Message memo] foobar

hoge

thank you for your hard work. [My name].
There was a call from bar of foo.
Please return.
TEL 000-000-000

Below is the source code.

TELmemo.py


#coding:utf-8
import time
from datetime import datetime
import csv
import pandas as pd
import os.path

def existsLog():
    #Create the log file if it does not exist
    if os.path.exists("telLog.csv") == False:
        f = open('telLog.csv','w')
        writer = csv.writer(f,lineterminator='\n')
        header = []
        header.append('To')
        header.append('From')
        header.append('incNm')
        header.append('Tel')
        header.append('Time')
        writer.writerow(header)
        f.close()

#Name entered,A method to suggest a phone number from a log with a company name
def suggestTelNo(df,nm,incNm):
    telNo = ""
    select = ""
    for index,row in df.iterrows():
        if row['From'] == nm and row['incNm'] == incNm:
            print("Maybe this phone number? : ",end="")
            print(row['Tel'])
            print("y/n: ",end="")
            select = input()
            telNo  = row['Tel']
            break
    if select == 'y':
        return telNo
    else:
        return None

#Method to output log
def mkLog(To,From,incNm,telNo):
    time = datetime.now()
    timeStr = time.strftime("%Y.%m.%d %H:%M:%S")
    info = [To,From,incNm,telNo,timeStr]

    with open('telLog.csv','a') as f:
        writer = csv.writer(f,lineterminator='\n')
        writer.writerow(info)
    f.close()

if __name__ == "__main__":

    f = open('TELmemo.txt','w')

    ln1 = "\n Thank you for your hard work. [My name]."
    ln2_1 = "of"
    ln2_2 = "I got a call from you."
    ln3 = "Please return."
    ln4 = "TEL "

    print("---The one who makes the text of the message mail---")
    print("---Message history---")

    existsLog()

    #Data frame for phone number suggestion
    df = pd.read_csv('telLog.csv',encoding='UTF-8')
    del df['Time']
    #Display message history
    print(df)

    print("\n * Names are omitted.")

    print("To whom?:",end="")
    to = input()
    print("From where?")
    print("Company name:",end="")
    incNm = input()
    print("name:",end="")
    nm = input()
    ln2 = incNm + ln2_1 + nm + ln2_2

    #Name entered,The process of suggesting a phone number from a log with a company name
    tel = suggestTelNo(df,nm,incNm)
    #Enter your phone number when you call for the first time
    if tel is None:
        print("TEL:",end="")
        tel = input()
        ln4 = ln4 + tel
    #Show phone number if you have called in the past
    else:
        print("TEL:" + tel)
        ln4 = ln4 + tel
    #Output log
    mkLog(to,nm,incNm,tel)

    #Create subject
    sub = "[Message memo]" + incNm + nm + "Mr" + '\n'
    #Divide and store the wording to be included in the text
    msg = (sub,to+"Mr.",ln1,ln2,ln3,ln4)

    #Write the text line by line to a txt file and output to the screen
    for line in msg:
        print(line)
        f.write(line + '\n')

    f.close()
    #I'll just wait for 3 seconds(To check the contents)
    time.sleep(3)
    exit()

Recommended Posts

I tried to streamline the standard role of new employees with Python
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to find the entropy of the image with python
I tried to improve the efficiency of daily work with Python
I tried to get the authentication code of Qiita API with Python.
I tried to get the movie information of TMDb API with Python
I tried to predict the behavior of the new coronavirus with the SEIR model.
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to solve the problem with Python Vol.1
I tried to summarize the string operations of Python
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University
I tried "gamma correction" of the image with Python + OpenCV
I tried to simulate how the infection spreads with Python
I tried to find the average of the sequence with TensorFlow
[Python] I tried to visualize the follow relationship of Twitter
I tried to divide the file into folders with Python
I tried to find out how to streamline the work flow with Excel x Python ④
I tried to find out how to streamline the work flow with Excel x Python ⑤
I tried to put out the frequent word ranking of LINE talk with Python
I tried to automate the article update of Livedoor blog with Python and selenium.
I tried to find out how to streamline the work flow with Excel x Python ①
I tried to visualize the characteristics of new coronavirus infected person information with wordcloud
I tried to find out how to streamline the work flow with Excel x Python ③
I tried to compare the processing speed with dplyr of R and pandas of Python
The 15th offline real-time I tried to solve the problem of how to write with python
Python3 standard input I tried to summarize
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to solve the ant book beginner's edition with python
I tried to automate the watering of the planter with Raspberry Pi
I want to output the beginning of the next month with Python
I tried to create a list of prime numbers with python
I tried to expand the size of the logical volume with LVM
I tried to automatically collect images of Kanna Hashimoto with Python! !!
PhytoMine-I tried to get the genetic information of plants with Python
How to write offline real time I tried to solve the problem of F02 with Python
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
I tried "smoothing" the image with Python + OpenCV
I tried hundreds of millions of SQLite with python
I tried to find out how to streamline the work flow with Excel × Python, my article summary ★
I tried "differentiating" the image with Python + OpenCV
I tried to save the data with discord
Since the stock market crashed due to the influence of the new coronavirus, I tried to visualize the performance of my investment trust with Python.
I tried to get CloudWatch data with Python
I tried to correct the keystone of the image
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 1
I tried to output LLVM IR with Python
I tried "binarizing" the image with Python + OpenCV
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I tried to automate sushi making with python
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 2
I touched some of the new features of Python 3.8 ①
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
I tried to verify and analyze the acceleration of Python by Cython
I tried to analyze the negativeness of Nono Morikubo. [Compare with Posipa]
I tried to visualize the text of the novel "Weathering with You" with WordCloud
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
I tried to analyze the New Year's card by myself using python
I tried to predict the price of ETF