This file contains 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
from PyQt5.QtWidgets import QFileDialog, QApplication | |
from PyQt5 import QtWidgets | |
def select_files(directory_location=None): | |
qtapp = QApplication([directory_location]) | |
qtwgt = QtWidgets.QWidget() | |
filenames, _ = QFileDialog.getOpenFileNames(qtwgt) | |
return filenames |
This file contains 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
import tkinter as tk | |
from tkinter import filedialog | |
root = tk.Tk() | |
root.withdraw() | |
file_path = filedialog.askopenfilename() | |
print(file_path) |
This file contains 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
import xlrd | |
import sys | |
class ExcelToList(): | |
def __init__(self, file, sheet): | |
self.file = file | |
self.sheet = sheet | |
def convert(self): |
This file contains 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/python | |
# -*- coding: utf-8 -*- | |
# Using curl to get data from https://ipinfo.io/json | |
# Template from pycurl documentation | |
# http://pycurl.io/docs/latest/quickstart.html#examining-response-headers | |
import pycurl #curl library | |
import certifi #HTTP over TLS/SSL library | |
from io import BytesIO #Buffered I/O implementation using an in-memory bytes buffer. |
This file contains 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
from openpyxl import load_workbook | |
from openpyxl import Workbook | |
import os | |
# Read data from active worksheet and return it as a list | |
def reader(file): | |
global path | |
abs_file = os.path.join(path, file) | |
wb_sheet = load_workbook(abs_file).active |
This file contains 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
#!/usr/bin/python3 | |
import argparse | |
import os | |
def path(): | |
parse = argparse.ArgumentParser( | |
add_help=True, description="Organize your files to different directories according to their type") | |
parse.add_argument('directory_path', type=str, default='./', |
This file contains 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
import requests | |
def get_temperature(json_data): | |
temp_in_celcius = json_data['main']['temp'] | |
return temp_in_celcius | |
def get_weather_type(json_data): | |
weather_type = json_data['weather'][0]['description'] | |
return weather_type |
This file contains 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
#!python3 | |
# -*- coding: utf-8 -*- | |
import openpyxl | |
import sys | |
#inputs | |
print("This programme writes the data in any Comma-separated value file (such as: .csv or .data) to a Excel file.") | |
print("The input and output files must be in the same directory of the python file for the programme to work.\n") |
This file contains 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
from urllib.request import urlopen | |
from bs4 import BeautifulSoup | |
quote_page = 'http://www.cricbuzz.com/cricket-match/live-scores' | |
page = urlopen(quote_page) | |
soup = BeautifulSoup(page,'html.parser') | |
update=[] | |
for score in soup.find_all('div',attrs={'class':'cb-col cb-col-100 cb-lv-main'}): |
This file contains 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
import sys | |
from PIL import Image | |
from PIL.ExifTags import TAGS | |
image_file = sys.argv[1] | |
image_name = image_file.split(".")[0] | |
try: | |
image = Image.open(image_file) | |
except IOError: |