Skip to content

Commit

Permalink
Merge pull request #4 from gaelforget/gfdev01
Browse files Browse the repository at this point in the history
use readlines in place of CSV, DataFrames
  • Loading branch information
gaelforget committed Sep 27, 2020
2 parents 56bbc08 + 1f2ffea commit 1c6f759
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 1 addition & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
name = "OceanStateEstimation"
uuid = "891f6deb-a4f5-4bc5-a2e3-1e8f649cdd2c"
authors = ["gaelforget <gforget@mit.edu>"]
version = "0.1.3"
version = "0.1.4"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
FortranFiles = "c58ffaec-ab22-586d-bfc5-781a99fd0b10"
MITgcmTools = "62725fbc-3a66-4df3-9000-e33e85b3a198"
MeshArrays = "cb8c808f-1acf-59a3-9d2b-6e38d009f683"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
CSV = "0.6, 0.7"
DataFrames = "0.19, 0.20, 0.21"
FortranFiles = "0.6"
MITgcmTools = "0.1"
MeshArrays = "0.2"
Expand Down
14 changes: 8 additions & 6 deletions src/OceanStateEstimation.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module OceanStateEstimation

using CSV, DataFrames, Statistics
using Statistics
using FortranFiles, MeshArrays, MITgcmTools
export get_from_dataverse, get_ecco_files

Expand All @@ -19,14 +19,16 @@ nams = nams.name[:]
```
"""
function get_from_dataverse(lst::String,nam::String,pth::String)
tmp = CSV.File(lst) |> DataFrame!
ii = findall([occursin("$nam", tmp[i,:name]) for i=1:size(tmp,1)])
tmp=readlines(lst)
ID=[parse(Int,tmp[j][1:findfirst(isequal(','),tmp[j])-1]) for j=2:length(tmp)]
name=[tmp[j][findfirst(isequal(','),tmp[j])+1:end] for j=2:length(tmp)]
ii = findall([occursin("$nam", name[i]) for i=1:length(ID)])
!isdir("$pth"*"$nam") ? mkdir("$pth"*"$nam") : nothing
for i in ii
ID=tmp[i,:ID]
nam1=tmp[i,:name]
id1=ID[i]
nam1=name[i]
nam2=joinpath("$pth"*"$nam/",nam1)
run(`wget --content-disposition https://dataverse.harvard.edu/api/access/datafile/$ID`);
run(`wget --content-disposition https://dataverse.harvard.edu/api/access/datafile/$id1`);
run(`mv $nam1 $nam2`);
end
end
Expand Down

0 comments on commit 1c6f759

Please sign in to comment.