Skip to content

Instantly share code, notes, and snippets.

@linlincheng
linlincheng / ipak.R
Created November 2, 2016 17:03 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
#Linlin Cheng
#Proj 5. tuning file1
library(caret)
library(xgboost)
library(readr)
library(dplyr)
library(tidyr)
########################
#Linlin Cheng
#Proj.5 Main Script
#09/21/2016
#loading packages:
library(dplyr)
library(VIM)
library(ggplot2)
library(ggmap)
library(glmnet)
#Step 4. Create the item info file:
import itertools
merged_item_list = list(itertools.chain(*item_url_list))
driver = webdriver.Chrome()
final_item_result_list = []
for url in merged_item_list:
try:
#save new_list, a list of dictionaries to a csv file:
keys = tmp_list[0].keys()
with open("event_list.csv", "w") as f:
dict_writer = DictWriter(f, keys, delimiter=",")
dict_writer.writeheader()
for value in tmp_list:
dict_writer.writerow(value)
import urllib2
from bs4 import BeautifulSoup
import requests
import re
import urlparse
from selenium import webdriver
from csv import DictWriter
import json