Skip to content

Instantly share code, notes, and snippets.

View jtrive84's full-sized avatar

James Triveri jtrive84

View GitHub Profile
@jtrive84
jtrive84 / ROracleAPI.R
Created November 21, 2016 05:53
A suite of ROracle wrapper functions used to write R dataframes to Oracle, and read Oracle tables into R dataframes.
library(ROracle)
Sys.setenv(TZ='America/Chicago')
Sys.setenv(ORA_SDTZ='America/Chicago')
#=============================================
# Upload dataframe as Oracle database table |
#=============================================
dfToOracle <- function(dataframe,
tablename,
@jtrive84
jtrive84 / dictionary.txt
Created November 27, 2016 04:50
A file to use for various Python tutorials
A
abactinally
Abassieh
Abbottstown
Abe
abevacuation
abiogenesist
ablauts
aboideaus
Aboukir
@jtrive84
jtrive84 / csv.writer_Usage.py
Created November 27, 2016 05:02
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"` to csv.writer instance.
"""
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"`
to csv.writer instance.
"""
import csv
fsrc_pth = "src_pth"
fdst_pth = "dst_pth"
with open(fdst_pth, 'w') as f1:
@jtrive84
jtrive84 / Working_with_cx_Oracle.md
Created November 27, 2016 06:27
Introduction to accessing Oracle data from Python using the cx_Oracle library.

Introduction to cx_Oracle

cx_Oracle is a third-party Python library that facilitates Oracle-to-Python database communication. A cursor is a control structure that enables traversal over the records in a database. This is Python's primary means of accessing database table data. The setup is:

  • Create a connection object
  • Define a cursor and call the cursor() method on the connection object
  • Construct a query string for the data of interest
  • Pass the query string to the cursor's execute method
@jtrive84
jtrive84 / ticker_data.csv
Last active November 28, 2016 01:59
A sample file for `An Introduction to sqlite3` gist.
DATE TICKER CLOSE
20161125 GE 31.440001
20161123 GE 31.34
20161122 GE 31.18
20161121 GE 30.870001
20161118 GE 30.67
20161117 GE 30.790001
20161116 GE 30.74
20161115 GE 30.75
20161114 GE 30.51
@jtrive84
jtrive84 / Python_Higher_Order_Functions.md
Created November 28, 2016 02:21
Introduction to Python's higher order functions and typical usage scenarios.
@jtrive84
jtrive84 / Introduction_to_sqlite3.md
Last active July 22, 2024 08:55
Introduction to Python's sqlite3 library and typical usage scenarios.

Introduction to SQLite in Python

Relevant Links:


SQLite is a C library that provides a lightweight disk-based database that doesn't require a separate server process. Applications can use SQLite for internal data storage. It's also possible to prototype an application using SQLite then later migrate to a more

@jtrive84
jtrive84 / Python_Data_Structures_and_Iteration.md
Created November 28, 2016 02:24
An introduction to common Python data structures and iteration.

Python Data Structures and Iteration

The first part of this introduction will discuss two very useful functions: enumerate and zip:

@jtrive84
jtrive84 / generate_dircolors.txt
Created December 6, 2016 02:45
Command to generate user DIR_COLORS file
cd && dircolors -p > .dircolors
@jtrive84
jtrive84 / Fire_Claims.csv
Created December 24, 2016 02:16
Sample Fire Claims table for DeMorgan's Laws blog post
CLAIM_ID EXPOSURE_ID STATE BLD_VALUE BLD_AGE CLAIM_AMT
695433 POL0004653 IL 1337609 7 1337609
621498 POL0002262 TN 509477 35 509477
818474 POL0009754 CT 953878 38 953878
785806 POL0002506 OR 106964 55 106964
799534 POL0002989 IL 469804 108 469804
729094 POL0005797 TN 894399 35 100000
610517 POL0005640 CT 532730 60 532730
888963 POL0005099 OR 1255253 34 1255253
607409 POL0003997 IL 688008 64 100000