Skip to content

Instantly share code, notes, and snippets.

View francisco-ltech's full-sized avatar

Francisco Ruiz A francisco-ltech

View GitHub Profile
@francisco-ltech
francisco-ltech / renderers.py
Created December 18, 2023 09:14 — forked from erny/renderers.py
FastAPI Simple content negotiation
"""Simple content negotiation
Usage:
Example 1:
from renderers import render
@router.post("/myapp/items/")
async def api_login(item: Item, accept: Optional[str] = Header(default='application/jwt')):
import duckdb
from deltalake import DeltaTable
# Read delta table using delta lake Python package
dt = DeltaTable(“abfs://container/path-to-delta-table/my-table”, storage_options=storage_options)
# Convert to PyArrow dataset
ds = dt.to_pyarrow_dataset()
# Connect to in-memory duckdb database
@francisco-ltech
francisco-ltech / deltalake-api-endpoint.py
Created December 24, 2020 16:46
Json API endpoint for Delta Lake
from deltalake import DeltaTable
from flask import request, jsonify
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/read-delta-table', methods=['GET'])
def home():
dt = DeltaTable("/tmp/delta/students-delta-table/")
@francisco-ltech
francisco-ltech / setup.md
Last active April 11, 2020 16:23
Manage Python versions with pyenv

Install on OSX/Mac

$ brew install pyenv 
$ pyenv install 3.7.5
$ pyenv global 3.7.5
@francisco-ltech
francisco-ltech / regex_validation.py
Created May 15, 2019 07:27
Search for patterns in log files
#check the las file on the result of the parseline function
#return (logline, 0) for unsucces
#or
#return (logline, 1) for success
%python
APACHE_ACCESS_LOG_PATTERN = '^(\S+) (\S+) (\S+) \[([\w:/]+\s[+\-]\d{4})\] "(\S+) (\S+)\s*(\S*)" (\d{3}) (\S+)'
import re
from pyspark.sql import Row
def parse(line):