Skip to content

Commit

Permalink
use Downloads, rm HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeason committed Sep 5, 2021
1 parent 2641661 commit bbb0e41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name = "FamaFrenchData"
uuid = "bd2a388e-9788-4ef7-9fc3-f4c919ffde82"
authors = ["Tyler Beason <tbeas12@gmail.com>"]
version = "0.3.1"
version = "0.4.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
CSV = "^0.7.6, 0.8"
DataFrames = "0.19.4, 0.20, 0.21, 0.22, 1"
HTTP = "^0.8.11, 0.9"
ZipFile = "0.8.4, 0.9"
julia = "^1.3"

Expand Down
13 changes: 9 additions & 4 deletions src/FamaFrenchData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Julia package for easy access to the Ken French Data Library files. See `readFam
"""
module FamaFrenchData

using HTTP
using Downloads
using CSV
using ZipFile
using DataFrames
Expand Down Expand Up @@ -31,7 +31,8 @@ Returns three pieces:
"""
function readFamaFrench(ffn;kwargs...)
if !isfile(ffn)
io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body)
io = IOBuffer()
Downloads.download(pathtoFamaFrench(ffn),io)
z = ZipFile.Reader(io)
ff = first(z.files)
else
Expand All @@ -52,7 +53,8 @@ Saves the extracted CSV file from `ffn` to local file `savename`.
"""
function downloadFamaFrench(savename,ffn)
open(savename,"w") do f
io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body)
io = IOBuffer()
Downloads.download(pathtoFamaFrench(ffn),io)
z = ZipFile.Reader(io)
ff = first(z.files)
for s in readlines(ff)
Expand All @@ -77,7 +79,10 @@ function listFamaFrench(;refresh::Bool = false)
if refresh
# grabs filenames from website
wname = "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html"
hs=String(HTTP.request("GET",wname).body)
io = IOBuffer()
Downloads.download(wname,io)
hs = String(take!(io))
close(io)
regx = r"(?<=ftp\/)(.*)(?=_CSV)"
res=collect(eachmatch(regx,hs))
nms = getfield.(res,:match)
Expand Down

0 comments on commit bbb0e41

Please sign in to comment.