Last active
March 5, 2025 15:46
-
-
Save misraX/399f19920821758cda586c2e82aedc65 to your computer and use it in GitHub Desktop.
Bash Script To Install Python Packages and Generate requirements.txt Inside Python Virtualenv.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Created By: misraX | |
# Github: github.com/misrax | |
# License: MIT | |
# CopyWrite: 2017 | |
# Bash script to install and generate pip requirements.txt from inside a virtualenv. | |
# By using pip freeze to creat a list of all the virtualenviroment pip packeges. | |
# It's just a simple way of creating the pip requirements.txt for a development use. | |
# usage pip-install package1 package2 package3 .. package(n)... etc | |
# | |
packages=($1) | |
echo "Starting to install packages, Hooopa....." | |
#check virtualenv path | |
if [[ "$VIRTUAL_ENV" != "" ]]; then | |
echo "You are in a working virtualenv $VIRTUAL_ENV"; | |
# virtual_env > check if packages is empty .. if [[ ]]; then | |
if [[ "$packages" != "" ]]; then | |
pip install "${packages[@]}"; | |
echo "Whre do u wanna save your requirements.txt type the path and click [ENTER]" | |
ls "$VIRTUAL_ENV" | |
read requirements_path | |
# virtual_env > > package > if read is empty ... if [[ ]]; then | |
if [[ "$requirements_path" == "" ]]; then | |
echo "Oh pleae, Enter something :D, now to call this script again use prepare" | |
exit 1; | |
# virtual_env > packages > read > if virtualevn/read is a valid directory.. elif [[ ]]; then | |
elif [[ -d "$VIRTUAL_ENV/$requirements_path" ]]; then | |
#statements | |
echo "creating requirements.txt"; | |
pip freeze > "$VIRTUAL_ENV/$requirements_path/requirements.txt" | |
# > virtul_env > package > read > not a valid directory .. else; fi | |
else | |
echo "This is not a vail directory under $(ls $VIRTUAL_ENV) path" | |
fi | |
# virtual_env > packages .. else; fi | |
else | |
echo "Please enter at least one package to install"; | |
exit 1; | |
fi | |
# virtual_env .. else; fi | |
else | |
echo "You are not in a working virtualenv" | |
echo "Exiting .........." | |
exit 1; | |
fi | |
# | |
#TODO | |
#adding enviroments variable to set DJANG_PATH and REQUIRMETS_PATH. | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import os
import pandas as pd
import numpy as np
from math import radians, sin, cos, atan2, sqrt
from datetime import datetime
-----------------------------------------------------------------------------
CONFIGURATION
-----------------------------------------------------------------------------
DATA_FOLDER = "./" # Folder where your Excel files are stored
EXCEL_FILES = [
# List all your Excel filenames here:
"WK.xlsx",
"27727861641.xlsx",
"G(1).xlsx",
"Schalk Pienaar.xlsx",
"CR.xlsx",
"BP_1123383_-Police_Case_Query-_AMA.xlsx",
"summary of cell numbers.xlsx",
"Manie 27823078393_1.xlsx",
"Manie 27823078393_2.xlsx"
]
Update these lists as needed or glob them automatically if you prefer.
Phone number references (update to match your data format exactly)
MANIE = "+27823078393"
SP = "+27824634777"
GG = "+27637762604"
JU = "+27727861641"
CALLIE = "+27834124723"
WK = "+27825248358" # Example victim
Columns in your Excel data (update to match your actual column names)
COL_CALLING = "CallingNumber" # e.g. "MSISDN" or "CallingNumber"
COL_CALLED = "CalledNumber" # e.g. "Other Party"
COL_LAT = "Latitude"
COL_LON = "Longitude"
COL_DATE = "Start Date" # e.g. "StartDate", "Date/Time"
COL_DURATION = "Call Duration" # e.g. "Call Duration", "Duration"
-----------------------------------------------------------------------------
HELPER FUNCTIONS
-----------------------------------------------------------------------------
def load_all_excel(files, folder=DATA_FOLDER):
"""
Loads and concatenates all Excel files into a single pandas DataFrame.
"""
combined_df = pd.DataFrame()
for f in files:
path = os.path.join(folder, f)
if os.path.exists(path):
df = pd.read_excel(path)
combined_df = pd.concat([combined_df, df], ignore_index=True)
else:
print(f"WARNING: File not found -> {path}")
return combined_df
def haversine_distance(lat1, lon1, lat2, lon2):
"""
Calculate Haversine distance (in meters) between two lat/lon pairs.
"""
R = 6371_000 # Radius of Earth in meters
phi1, phi2 = radians(lat1), radians(lat2)
dphi = radians(lat2 - lat1)
dlambda = radians(lon2 - lon1)
-----------------------------------------------------------------------------
MAIN ANALYSIS
-----------------------------------------------------------------------------
def main():
# 1. Load & clean data
df = load_all_excel(EXCEL_FILES, DATA_FOLDER)
if df.empty:
print("No data loaded. Please check your file paths and names.")
return
if name == "main":
main()