library(tidyverse)
getwd()
#Extracted data from EIA see https://www.eia.gov/dnav/ng/ng_cons_sum_a_EPG0_veu_mmcf_m.htm
Gas_Cons <- read_csv("./Natural_Gas_Consumption_by_End_Use.csv",skip=6)
colnames(Gas_Cons) <- 	gsub(' Natural Gas Deliveries to Electric Power Consumers MMcf',"",colnames(Gas_Cons ) ) 
colnames(Gas_Cons) <- 	gsub(' ',"_",colnames(Gas_Cons ) ) 

colnames(Gas_Cons)[1] <- "Obs_Date"
State_Order <- sort(colnames(Gas_Cons[-1]))
Gas_Cons <- Gas_Cons[,c("Obs_Date",State_Order)]

Months <- substr(Gas_Cons$Obs_Date,1,3)
Years <- substr(Gas_Cons$Obs_Date,5,8)
Full_Dates <- 	paste("01", Gas_Cons$Obs_Date)

Gas_Cons$Month<- factor(Months,ordered = FALSE)
Gas_Cons$Year <- factor(Years,ordered = TRUE)
Gas_Cons$Obs_Date <- as.Date(Full_Dates, format = "%d %b %Y")


Col_Names <- colnames(Gas_Cons)
Gas_Cons <- Gas_Cons[,c("Year","Month",Col_Names)]
Gas_Cons[is.na(Gas_Cons )] <- 0

Gas_Cons <- Gas_Cons[Gas_Cons$Yeara>2014,]
Wyoming_Gas_Cons <- Gas_Cons[,c("Year","Month","Obs_Date","Wyoming")]
write_csv(Gas_Cons,

