add CSV download functions and set them as default and use in test

- replaced old ones from runtests
- need to remove CSVs in git repo
This commit is contained in:
Wataru Otsubo 2024-10-01 10:52:47 +09:00
parent 16d23ec4bb
commit d58a13793f
5 changed files with 107 additions and 14 deletions

View file

@ -10,7 +10,7 @@ using Dates
include("parse_qaqc_master_log.jl")
include("create_table.jl")
include("download_csv.jl")
include("import_data.jl")
"""
@ -37,11 +37,11 @@ Create database at `dbpath` and import data from CSV and master log files.
"""
function create_database_from_exported_csvs(
dbpath::AbstractString;
single_run_csv::AbstractString,
runlist_csv::AbstractString,
dispatch_csv::AbstractString,
hundred_csv::AbstractString,
jathubs_csv::AbstractString,
single_run_csv::AbstractString = DownloadCSVs.download_single_run_csv(),
runlist_csv::AbstractString = DownloadCSVs.download_runlist_csv(),
dispatch_csv::AbstractString = DownloadCSVs.download_dispatch_csv(),
hundred_csv::AbstractString = DownloadCSVs.download_hundred_run_csv(),
jathubs_csv::AbstractString = DownloadCSVs.download_jathub_csv(),
masterlog_dir::AbstractString,
)
db = create_database(dbpath)

61
src/download_csv.jl Normal file
View file

@ -0,0 +1,61 @@
"""
Functions to download result CSVs from Google Sheets.
All functions return the filename in `String`.
"""
module DownloadCSVs
using Downloads
"""
download_single_run_csv(outfile::AbstractString = tempname()) -> filename
# Example
```jldoctest
julia> file = PSBoardDataBase.DownloadCSVs.download_single_run_csv();
julia> using CSV
julia> using DataFrames
julia> CSV.read(file, DataFrame) isa DataFrame
true
```
"""
function download_single_run_csv(outfile::AbstractString = tempname())
URL_SINGLE_RUN_CSV::String = "https://docs.google.com/spreadsheets/u/1/d/128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU/export?format=csv&id=128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU&gid=408695746"
Downloads.download(URL_SINGLE_RUN_CSV, outfile)
end
"""
download_runlist_csv(outfile::AbstractString = tempname()) -> filename
"""
function download_runlist_csv(outfile::AbstractString = tempname())
URL_RUNLIST_CSV::String = "https://docs.google.com/spreadsheets/u/1/d/128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU/export?format=csv&id=128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU&gid=252134084"
Downloads.download(URL_RUNLIST_CSV, outfile)
end
"""
download_dispatch_csv(outfile::AbstractString = tempname()) -> filename
"""
function download_dispatch_csv(outfile::AbstractString = tempname())
URL_DISPATCH_CSV::String = "https://docs.google.com/spreadsheets/u/1/d/128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU/export?format=csv&id=128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU&gid=707598141"
Downloads.download(URL_DISPATCH_CSV, outfile)
end
"""
download_hundred_run_csv(outfile::AbstractString = tempname()) -> filename
"""
function download_hundred_run_csv(outfile::AbstractString = tempname())
URL_HUNDRED_RUN_CSV::String = "https://docs.google.com/spreadsheets/u/1/d/128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU/export?format=csv&id=128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU&gid=615256061"
Downloads.download(URL_HUNDRED_RUN_CSV, outfile)
end
"""
download_jathub_csv(outfile::AbstractString = tempname()) -> filename
"""
function download_jathub_csv(outfile::AbstractString = tempname())
URL_JATHUB_CSV::String = "https://docs.google.com/spreadsheets/u/1/d/128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU/export?format=csv&id=128qOseOy4QDotehYe4Wf2jj88tnwiXGVdR3NHrjcDYU&gid=303843601"
Downloads.download(URL_JATHUB_CSV, outfile)
end
end # module DownloadCSVs