Skip to content

Commit

Permalink
Add copycols=true to CSV.read calls since otherwise columns read in a…
Browse files Browse the repository at this point in the history
…re immutable
  • Loading branch information
caimichael authored and ethanmatlin committed Jun 25, 2019
1 parent 7f39855 commit cbb8d85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/data/load_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function load_data_levels(m::AbstractModel; verbose::Symbol=:low)
println(verbose, :low, "Reading data from $file...")

# Read in dataset and check that the file contains data for the proper dates
addl_data = CSV.read(file)
addl_data = CSV.read(file, copycols=true)

# Convert dates from strings to quarter-end dates for date arithmetic
format_dates!(:date, addl_data)
Expand Down Expand Up @@ -219,15 +219,15 @@ function load_cond_data_levels(m::AbstractModel; verbose::Symbol=:low)
println(verbose, :low, "Reading conditional data from $file...")

# Read data
cond_df = CSV.read(file)
cond_df = CSV.read(file, copycols=true)
format_dates!(:date, cond_df)

date_cond_end = cond_df[end, :date]

# Use population forecast as population data
population_forecast_file = inpath(m, "raw", "population_forecast_" * data_vintage(m) * ".csv")
if isfile(population_forecast_file) && !isnull(get_setting(m, :population_mnemonic))
pop_forecast = CSV.read(population_forecast_file)
pop_forecast = CSV.read(population_forecast_file, copycols=true)

population_mnemonic = get(parse_population_mnemonic(m)[1])
rename!(pop_forecast, :POPULATION => population_mnemonic)
Expand Down Expand Up @@ -284,7 +284,7 @@ Read CSV from disk as DataFrame. File is located in `inpath(m, \"data\")`.
"""
function read_data(m::AbstractModel; cond_type::Symbol = :none)
filename = get_data_filename(m, cond_type)
df = CSV.read(filename)
df = CSV.read(filename, copycols=true)

# Convert date column from string to Date
df[:date] = map(Date, df[:date])
Expand Down Expand Up @@ -463,7 +463,7 @@ end
function read_population_data(filename::String; verbose::Symbol = :low)
println(verbose, :low, "Reading population data from $filename...")

df = CSV.read(filename)
df = CSV.read(filename, copycols=true)
DSGE.format_dates!(:date, df)
sort!(df, :date)

Expand Down Expand Up @@ -498,7 +498,7 @@ function read_population_forecast(filename::String, population_mnemonic::Symbol;
if isfile(filename)
println(verbose, :low, "Loading population forecast from $filename...")

df = CSV.read(filename)
df = CSV.read(filename, copycols=true)
rename!(df, :POPULATION => population_mnemonic)
DSGE.format_dates!(:date, df)
sort!(df, :date)
Expand Down

2 comments on commit cbb8d85

@ethanmatlin
Copy link
Collaborator

Choose a reason for hiding this comment

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

@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/1574

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" cbb8d8582ccaa5fb8cd1eaf95fa5600b0b8e12d1
git push origin v0.6.0

Please sign in to comment.