Skip to content

Commit

Permalink
CSV deprecations and docstring updates and v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeason committed Aug 6, 2020
1 parent 10c643e commit 080aa9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/docs/build
Manifest.toml
/docs
/.vscode
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ os:
julia:
- 1.3
- 1.4
- 1.5
- nightly
notifications:
email: false
Expand Down
22 changes: 11 additions & 11 deletions src/FamaFrenchData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export readFamaFrench, downloadFamaFrench, listFamaFrench
const KFDLftp = "http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/"

"""
`readFamaFrench(ffn;kwargs...)`
readFamaFrench(ffn;kwargs...)
`ffn` can be the table name (in which case it is retreived from the web) or a path to the local file.
`kwargs` are passed to `CSV.read`. Missing values (`-99.99` or `-999`) are replaced with `missing`.
Expand Down Expand Up @@ -46,7 +46,7 @@ end


"""
`downloadFamaFrench(savename,ffn)`
downloadFamaFrench(savename,ffn)
Saves the extracted CSV file from `ffn` to local file `savename`.
"""
Expand All @@ -66,13 +66,13 @@ end


"""
`listFamaFrench(;refresh=false)`
listFamaFrench(;refresh=false)
Returns a vector of possible table names. Reads from `listFamaFrench.txt`.
When `refresh = true`, first crawls the website to find current list of tables, then overwrites `listFamaFrench.txt` with this list.
The selection of tables is rarely changed, so the provided list is likely sufficient.
"""
function listFamaFrench(;refresh = false)
function listFamaFrench(;refresh::Bool = false)
LFF_file = abspath(joinpath(@__DIR__, "..", "listFamaFrench.txt"))
if refresh
# grabs filenames from website
Expand Down Expand Up @@ -104,12 +104,12 @@ end
# UNEXPORTED FUNCTIONS
########################################
"""
parsefile(lines;kwargs...)
parsefile(lines;kwargs...)
The workhorse function behind `readFamaFrench`.
`lines` is an `IO`
`kwargs` are passed to `CSV.read`. Missing values (`-99.99` or `-999`) are replaced with `missing`.
`lines` is an `IO`.
`kwargs` are passed to `CSV.File`. Missing values (`-99.99` or `-999`) are replaced with `missing`.
Returns three pieces:
Expand All @@ -120,7 +120,7 @@ Returns three pieces:
- `filenotes::String` - notes at the top of the file
"""
function parsefile(lines;kwargs...)
csvopt = (missingstrings = ["-99.99","-999"],normalizenames = true,copycols = true,kwargs...)
csvopt = (missingstrings = ["-99.99","-999"],normalizenames = true,kwargs...)

stringarray = readlines(lines,keep=true)
striparray = strip.(stringarray)
Expand Down Expand Up @@ -152,7 +152,7 @@ function parsefile(lines;kwargs...)
dfvec = Vector{DataFrame}(undef,ntables)
for i in 1:ntables
ios = IOBuffer(string(stringarray[tranges[i]]...))
dfvec[i] = CSV.read(ios;csvopt...)
dfvec[i] = CSV.File(ios;csvopt...) |> DataFrame
rename!(dfvec[i],Symbol(first(names(dfvec[i]))) => :Date)
close(ios)
end
Expand All @@ -171,7 +171,7 @@ end


"""
`pathtoFamaFrench(ffn)`
pathtoFamaFrench(ffn)
Generates the full web path to the file.
"""
Expand All @@ -181,7 +181,7 @@ pathtoFamaFrench(ffn) = joinpath(KFDLftp,string(ffn, "_CSV.zip"))


"""
lastornothing(x) = isempty(x) ? nothing : last(x)
lastornothing(x) = isempty(x) ? nothing : last(x)
A helper function.
"""
Expand Down

2 comments on commit 080aa9e

@tbeason
Copy link
Owner Author

@tbeason tbeason commented on 080aa9e Aug 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/19098

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.4 -m "<description of version>" 080aa9e537e0545f9b2f843f8a348ea803559fce
git push origin v0.1.4

Please sign in to comment.