Skip to content

Commit

Permalink
use datahugger instead of url.
Browse files Browse the repository at this point in the history
  • Loading branch information
Liu committed Oct 23, 2023
1 parent fad40c5 commit 7d894d1
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions examples/sealevel-curve-extraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7d894d1

Please sign in to comment.