Skip to content

Instantly share code, notes, and snippets.

@tpjfern03
tpjfern03 / shell.sh
Last active November 28, 2018 18:23
Linux Snippets
#!/usr/bin/env bash
export DATE_0=`date +'%m/%d/%Y'`
export TIMESTAMP=`date +'%Y%m%d%H%M%S'`
PROGNAME=$(basename $0)
error_exit()
{
@tpjfern03
tpjfern03 / table.ctl
Created November 28, 2018 18:02
[Oracle Control File] Oracle Control File #oracle
LOAD DATA
INFILE csvDevices.csv
append
INTO TABLE UTIL_DEVICE
fields terminated by '^' optionally enclosed by '"'
trailing nullcols
(device_name "trim(:device_name)",
device_type "trim(:device_type)",
sub_station_abbr "trim(:sub_station_abbr)",
device_id "DEVICE_ID_SEQ.NEXTVAL" )
@tpjfern03
tpjfern03 / logging.yaml
Created November 28, 2018 18:00
[logging.yaml] Logging configs
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
@tpjfern03
tpjfern03 / main.py
Last active November 29, 2018 14:40
[Python Template] Starting Template #template
# Program: extractUDMdata.py
# Description: This is a program to extract the customer UDM from a formatted Excel file
#
# Author: Terence Fernandes
# Date: 03/16/2018
# Version: 1.0
# pyinstaller extractUDMdata.py --add-data=logging.yaml:. --add-data=extractUDMdata.ini:. --add-data=udmFile.xlsx:.
# OR pyinstaller -F extractUDMdata.py --hidden-import=_cffi_backend
# --hidden-import=_cffi_backend
# pyi_rth_qt4plugins.py
@tpjfern03
tpjfern03 / df2json.py
Last active May 20, 2016 14:46 — forked from mikedewar/df2json.py
A little script to convert a pandas data frame to a JSON object. Is there a better way?
"""
tiny script to convert a pandas data frame into a JSON object
"""
import ujson as json
import pandas
import numpy as np
df = pandas.DataFrame({
"time" : [1,2,3,4,5],
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@tpjfern03
tpjfern03 / pandas_dbms.py
Created May 20, 2016 14:29 — forked from catawbasam/pandas_dbms.py
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,