Skip to content

Instantly share code, notes, and snippets.

@iangow
Last active April 27, 2017 01:03
Show Gist options
  • Save iangow/4fbc003b102af5c9adae2709448ad57f to your computer and use it in GitHub Desktop.
Save iangow/4fbc003b102af5c9adae2709448ad57f to your computer and use it in GitHub Desktop.
Code to get data from WRDS into PostgreSQL

Go here for the latest.

@iangow
Copy link
Author

iangow commented Apr 24, 2017

@amarder

Above is my rough first pass at translating my wrds_fetch.pl from Perl into Python. It still depends on pipes, but much less so than the Python code (also my Python is much better than my Perl ever was, so this code is a bit easier to follow even though it's somewhat clunky due to some parts being almost line-for-line translations).

I think if one could replace likes like this:

cmd_template = "echo \"%s\" | "
cmd_template += "ssh -C %[email protected] 'qsas -stdio -noterminal ' 2>/dev/null"

with some other way of getting code (what goes in %s) into the SSH connection to the WRDS server, then this would work anywhere (including on Windows).

If you have any suggestion on that part, I could wrap it up to be a more complete replacement for the Perl code (translating the companion code in wrds_update.pl should be easier, as this is higher-level code).

@iangow
Copy link
Author

iangow commented Apr 24, 2017

@amarder

As a bonus, I included (see In [16]:) code to pull the data directly from WRDS into a Pandas data frame. The code that fixes types in PostgreSQL could adapted to fix column types in the Pandas data frame.

@iangow
Copy link
Author

iangow commented Apr 25, 2017

@amarder

Ignore the above. Better code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment