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
#https://stackoverflow.com/questions/27556751/unprotect-an-excel-file-programmatically | |
#Windows | |
def Remove_password_xlsx(filename, pw_str): | |
xcl = win32com.client.Dispatch("Excel.Application") | |
wb = xcl.Workbooks.Open(filename, False, False, None, pw_str) | |
xcl.DisplayAlerts = False | |
wb.SaveAs(filename, None, '', '') | |
xcl.Quit() |
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
import json, os | |
here = os.path.dirname(os.path.abspath(__file__)) | |
os.chdir(here) | |
f = open("database/locations.json", "r") # open the JSON with read access | |
data = json.load(f) | |
f.close() | |
#do here something with the "data" object like reading and manipulating data |
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
import openpyxl, os, datetime | |
here = os.path.dirname(os.path.abspath(__file__)) | |
os.chdir(here) | |
wb = openpyxl.load_workbook("mb51.xlsx") | |
sheet1 = wb[wb.sheetnames[0]] | |
date_time_str = sheet1.cell(4,3).value | |
date_time_obj = datetime.datetime.strptime(date_time_str, '%d.%m.%Y') | |
print(date_time_obj.isocalendar()[1]) |
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
# basic SQLite | |
import sqlite3 | |
db = sqlite3.connect("books-collection.db") | |
cursor = db.cursor() | |
cursor.execute("CREATE TABLE books (id INTEGER PRIMARY KEY, title varchar(250) NOT NULL UNIQUE, author varchar(250) NOT NULL, rating FLOAT NOT NULL)") | |
cursor.execute("INSERT INTO books VALUES(1, 'Harry Potter', 'J. K. Rowling', '9.3')") | |
db.commit() |
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
# basic 'hello world' server | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
return 'Hello, World' | |
#export environment variable via terminal: |
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
# basic login form | |
# main.py | |
from flask import Flask, render_template | |
from flask_wtf import FlaskForm | |
from wtforms import StringField, PasswordField, SubmitField | |
class LoginForm(FlaskForm): |
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
# allows python code to be embedded in html | |
#enables basic arithmetics | |
<body> | |
{{3*3}} | |
</body> | |
#pass over variables from the python backend to your HTML | |
# server.py | |
@app.route('/') |