Skip to content

Instantly share code, notes, and snippets.

View glauesppen's full-sized avatar
:octocat:
Focusing

Glaucia Esppenchutz glauesppen

:octocat:
Focusing
View GitHub Profile
@glauesppen
glauesppen / reports_pandas.py
Created September 6, 2017 14:34
Using pandas to report
import pandas as pd
from leilao.models import Lance
lista = ['PTN07-17A-SUCATAS', 'PTN07-17B-SUCATAS', 'PTN07-17C-SUCATAS','PTN07-17D-SUCATAS']
queryset = (
Lance.objects
.filter(lote__leilao__nome__in=lista)
.values('lote__leilao__nome', 'user__userprofile__nome', 'user__email', 'user__userprofile__telefone1', 'user__userprofile__telefone2')
.distinct()
@glauesppen
glauesppen / list_all_dirs.py
Created November 24, 2017 22:52
A path is passed and the function returns all directories and files in the tree.
import os
def list_dir(parent):
dir = os.listdir(parent)
for lists in dir:
directory = os.path.join(parent, lists)
print directory
if os.path.isdir(directory):
list_dir(directory)
@glauesppen
glauesppen / search_keyword.py
Created November 24, 2017 23:04
Function search in a text file for a keyword and return the sentences it belongs.
def search_text(text, keyword):
with open(text,'r') as t:
for period in t:
for sentence in period.split('.'):
if keyword in sentence:
print sentence
@glauesppen
glauesppen / amazon-rekognition.md
Created August 19, 2018 14:06 — forked from alexcasalboni/amazon-rekognition.md
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
@glauesppen
glauesppen / scalaforpy
Created January 2, 2020 14:49 — forked from stantonk/scalaforpy
Scala for Python Programmers, examples
/*
Notes:
Despite Scala's appearances, it is, in fact, a Statically Typed language.
It has just eliminated a great deal of the "type vomit" people are used
to seeing in Statically Typed languages (e.g. C, C++, Java). It often
can infer the type on its own. It also combines functional and
object-oriented programming paradigms in a fashion that feels similar
to Python.
*/
@glauesppen
glauesppen / split.py
Created January 22, 2020 18:37 — forked from kelvintaywl/split.py
Python Script to split CSV files into smaller files based on number of lines
import csv
import sys
import os
# example usage: python split.py example.csv 200
# above command would split the `example.csv` into smaller CSV files of 200 rows each (with header included)
# if example.csv has 401 rows for instance, this creates 3 files in same directory:
# - `example_1.csv` (row 1 - 200)
# - `example_2.csv` (row 201 - 400)
# - `example_3.csv` (row 401)