forked from Data4Democracy/drug-spending
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pharma_Lobby.R
32 lines (23 loc) · 856 Bytes
/
Pharma_Lobby.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require(RPostgreSQL)
pw <- {
"REDACTED"
}
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname = "jacob",
host = "localhost", port = 5432,
user = "jacob", password = pw)
V = function(x) {dbGetQuery(x, conn = con)}
V("Drop table if exists LobbyIndus")
V(
"CREATE TABLE LobbyIndus(
client varchar(50),
sub varchar(50),
total float,
year char (4),
catcode varchar(10)
)
")
V("Copy LobbyIndus from '/home/jacob/Data for Democracy/lob_indus.txt' with CSV QUOTE '|' DELIMITER ',';")
V("Drop table if exists pharmalobby")
V("Create table PharmaLobby as select * from Lobbyindus where catcode in ('H4000', 'H4100', 'H4200', 'H4300', 'H4400', 'H4500');")
write.csv(V("Select * from PharmaLobby;"), file="/home/jacob/Data for Democracy/drug-spending/Lobbying Data/Pharma_Lobby.csv")