From 7d894d1dfd7525d8f467b9b79f6f2e47edab46d4 Mon Sep 17 00:00:00 2001 From: Liu Date: Mon, 23 Oct 2023 23:12:49 +0200 Subject: [PATCH] use datahugger instead of url. --- examples/sealevel-curve-extraction.jl | 41 ++++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/examples/sealevel-curve-extraction.jl b/examples/sealevel-curve-extraction.jl index 5088b88..6340f72 100644 --- a/examples/sealevel-curve-extraction.jl +++ b/examples/sealevel-curve-extraction.jl @@ -4,31 +4,32 @@ using Interpolations using DataFrames using CSV using HTTP -#import OpenScienceFramework as OSF +using PyCall +dh = pyimport("datahugger") +url = "https://osf.io/5yka4/" #url of the folder +dh.get(url,"data/all-sealevel") -function sealevel(url,name) - #=osf = OSF.Client(; token = alexa) # put your OSF token here - proj = OSF.project(osf; title="CarbonKitten") - dir = OSF.directory(proj, "Analysis") - subdir = OSF.directory(dir, "CarboKitten") - subsubdir = OSF.directory(subdir, "OSF Storage") - file = OSF.file(subsubdir, name) - data = read(file) - url = OSF.url(file) - =# - headers = Dict("Authorization" => "Bearer $token") - response = HTTP.get(url,headers)# copy paste Sealelvel data from a database - data = split(String(response.body), "\n") +function sealevel() + #headers = Dict("Authorization" => "Bearer $token") + #response = HTTP.get(url)# copy paste Sealelvel data from a database + #data = split(String(response.body), "\n") #data_float64 = parse.(Float64, data) - CSV.write("data/all-sealevel/$name.csv", DataFrame(sl=data)) + folder_path = "data/all-sealevel" + files = readdir(folder_path) + files = filter(x -> occursin(".txt", x), readdir(folder_path)) + + for file in files + file_path = joinpath(folder_path,file) + name, _ = splitext(file) + data = read(file_path, String) + CSV.write("data/all-sealevel/$name.csv", DataFrame(sl = data)) + end + + #CSV.write("data/all-sealevel/$name.csv", DataFrame(sl=data)) end -url = "https://osf.io/download/zntw8/" #local_path = "data/all-sealevel/sl.csv" -name = "Auto000_Allo000_Stoch100V2" -token = "the token"; -#localfile = "data/" -sealevel(url,name) +sealevel() #=t = 1 : 2500 sl = sin.(2π .* t ./ 0.2) #file = open("data/all-sealevel/sl1.csv","w")