Skip to content

Instantly share code, notes, and snippets.

View sergiolucero's full-sized avatar
💭
coding the days away

Sergio Lucero sergiolucero

💭
coding the days away
View GitHub Profile
@sergiolucero
sergiolucero / bestplots.py
Created September 27, 2018 23:05
my best plots
# galería de gráficos: gasolinas (heatmap+violines) + ipsa + other good ones
import seaborn as sns
import pandas as pd
#1 IPSA:
#2 CNE
#3
@sergiolucero
sergiolucero / s3down.py
Created November 11, 2018 21:54
download s3 files
import boto3
import os, sys
s3 = boto3.resource('s3')
def down(canal,token):
x = os.popen(f'lss3 matinales/audio/{canal}/|find "{token}"').read()
files=[f for f in x.split() if 'mp3' in f]
print(files)
for f in files:
@sergiolucero
sergiolucero / comunas_shapefile.py
Created December 7, 2018 19:24
chile comunas shapefile
# https://gis.stackexchange.com/questions/113799/how-to-read-a-shapefile-in-python
# http://geospatialpython.com/2011/09/reading-shapefiles-from-cloud.html
# https://medium.com/@loldja/reading-shapefile-zips-from-a-url-in-python-3-93ea8d727856
# http://andrewgaidus.com/Reading_Zipped_Shapefiles/
# https://gis.stackexchange.com/questions/113799/how-to-read-a-shapefile-in-python
@sergiolucero
sergiolucero / tv_scraper.py
Created March 30, 2019 13:40
television scraper
import os, requests, time
import sqlite3, pandas as pd
from bs4 import BeautifulSoup
STATIC_FOLDER = os.getenv('STATIC_FOLDER')
CANALES = ['rec-tv','canal-13-c','mega','canal-13','tvn','chilevision','ucv-tv',
'tnt','la-red','fox','tnt','hbo','sony','axn','warner','a-e-mundo',
'universal-channel','space','fx']
# 'tvn-24h'
@sergiolucero
sergiolucero / csv_to_geojson.py
Created June 5, 2019 18:48
shapefile_geojson from CSV
import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import Point
import fiona
df = pd.read_csv('data.csv')
geometry = [Point(xy) for xy in zip(df.x, df.y)]
crs = {'init': 'epsg:2263'} #http://www.spatialreference.org/ref/epsg/2263/
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)
@sergiolucero
sergiolucero / outlook_reader.py
Created June 6, 2019 20:23
parsing outlook folders
import os, time
from pprint import pprint
from collections import defaultdict
from win32com.client import Dispatch
t0 = time.time()
outlook=Dispatch("Outlook.Application").GetNamespace("MAPI")
#inbox = outlook.GetDefaultFolder("6")
confi = outlook.Folders(2).Folders(2) # found by trial and error
counts = defaultdict(int)
@sergiolucero
sergiolucero / graphqlapp.py
Created June 20, 2019 13:33
basic flask-graphql app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from flask_graphql import GraphQLView
#################################
app = Flask(__name__)
app.debug = True
@sergiolucero
sergiolucero / cliente_deudor.json
Last active July 12, 2019 14:21
PentaCD dataset
{
"nodes": [
{
"id": "DAG INGENIERIA Y CONSTRU",
"group": 0
},
{
"id": "ALBEMARLE LIMITADA (ROCK",
"group": 1
},
import requests, pandas as pd
from bs4 import BeautifulSoup
CLIO_DEF = 'https://www.yapo.cl/chile/inmuebles?ca=15_s&l=0&q=casa&cmn=&st=a'
def text_search(bs, classname):
return [p0.text.strip()
for p0 in bs.find_all('span', attrs={'class': classname})]
def scrape_yapo(url = CLIO_DEF):
import requests, pandas as pd
from bs4 import BeautifulSoup
CLIO_DEF = 'https://www.yapo.cl/chile/inmuebles?ca=15_s&l=0&q=casa&cmn=&st=a'
def text_search(bs, classname):
return [p0.text.strip()
for p0 in bs.find_all('span', attrs={'class': classname})]
def scrape_yapo(url = CLIO_DEF):