Posts

Day 32 - Python Script to track Available COVID-19 Vaccine Slots for 18+ in India

Image
 Booking a COVID-19 vaccination slot reminds me of good old days of booking a TATKAL ticket in   Indian train. If you are lucky and very fast with Keyboard then we would be able to book the train   ticket  under TATKAL quota. Otherwise Surprise !!!  Same rule applies here too but we don't have idea about the next available slot timings for vaccination. When is the next slot going to open ? Still it's a suspense for us. By the time we come to know that there are few slots available, CoWIN portal ( https://www.cowin.gov.in/home ) shows that it's already booked. I have observed that people are struggling to find an available slots in their locality. So I thought of writing a python script using public API to track the available COVID-19 vaccine slots in the entire city. Task for interested folks who want to send an alert to a group/channel: Please trigger an email or message on WhatsApp/Telegram group whenever you get any data in the output file - "18plus...

DAY 31 - Organize a Secret Santa Game in your organization using a Python Script

Image
 The script will  perform below mentioned activities: 1.      Assign a Secret Santa randomly to each participant 2.      Save the final extract into an excel file 3.      Send an automated mail to each Secret Santa with a complete address details of his/her Secret Santa Child   Sample final extract file: Sample Mail Format: Prerequisite: 1.       Collect information of participants in an excel file as shown below. 2.  Click on “Manage your Google Account” > Security > Less secure app access Turn ON access for less secure app Note - This setup is required to send a mail from Gmail using Python script   Python Script: # -*- coding: utf-8 -*- """ Created on Wed Dec 2 12:15:58 2020 @author: Rakesh.Ranjan """ import random import pandas as pd import numpy as np import os import string  ss_keys = [] ssc_values = [] input_file_name = "Secret Santa - Information needed-Tes...

Day 30 - Learn the concept of comprehension,lambda,map,filter,reduce via simple examples

Image
 # -*- coding: utf-8 -*- """ Created on Tue Sep  8 11:20:22 2020 @author: Rakesh.Ranjan """ def square(x):     return x**2   def even(x):     return x%2 == 0   numbers = [1,2,3,4]  #Comprehension #1. the expression inside the brackets first starts with the operation/output that you desire, and then loops and conditionals occur in the same order of the regular code.  lc_square = [numbers[i]**2 for i in range(len(numbers))] print('Comprehension example:',lc_square) #lambda  #lambda input parameter(s):operation/output  countries = ['India','Pakistan','Bhutan','Nepal','Bangladesh'] func_lambda = lambda x: x.lower() print('lambda example:',func_lambda('India')) #A. Map  #map(function,iterable object)  #1. The function here can be a lambda function or a function object.  #2. The iterable object can be a string, list, tuple, set or dictionary.  lm_map = map(square, numbers)   print('map exa...

Populate a MS Word Template Using Python Script

Image

Day 29 - Populate a MS Word template With a Python Script

Image

Day 28 - Play with MS-Word using Python Script

Image
Sometimes we have to scan the data from MS-Word so that we would  proceed with next set of activities. Here you go, buddy !!!! You can use this script to read the content of MS-word + Add a new paragraph in the doc + Add a new image in the doc Python Script: # -*- coding: utf-8 -*- """ Created on Tue Jun 16 18:43:01 2020 @author: Rakesh.Ranjan """ import docx import pandas as pd doc = docx.Document("C:\\Users\\Rakesh.Ranjan\\Desktop\\LND\\MS-DOC.docx") #reading 1st paragraph single_para = doc.paragraphs[0] print(single_para.text) line_number = 0 #Reading all Paragraphs all_paras = doc.paragraphs print(len(all_paras)) #creating an empty dataframe column_names = ["line_number","line_text"] doc_df = pd.DataFrame(columns = column_names) #reading each paragraph and storing it in the dataframe for para in all_paras:     doc_df = doc_df.append({"line_number":line_number, "line_tex...