Skip to content

Instantly share code, notes, and snippets.

@slarge
Created March 7, 2017 13:21
Show Gist options
  • Save slarge/8bf344edc8e05d2533fcd002aa6ffee4 to your computer and use it in GitHub Desktop.
Save slarge/8bf344edc8e05d2533fcd002aa6ffee4 to your computer and use it in GitHub Desktop.
navigate SD
rm(list = ls())
# Load this package, install it if you don't have it already
library(jsonlite)
# Change the active year.
ActiveYear <- 2016
rawsl <- jsonlite::fromJSON(paste0("http://sd.ices.dk/services/odata3/StockListDWs3?$filter=ActiveYear%20eq%20",
ActiveYear),
simplifyDataFrame = TRUE)$value
# colnames(rawsl)
# [1] "ID" "StockCode" "OldStockCode"
# [4] "ActiveYear" "Description" "SpeciesScientificName"
# [7] "SpeciesCommonName" "EcoRegion" "ExpertGroup"
# [10] "ExpertGroupDescription" "AdviceDraftingGroup" "AdviceDraftingGroupDescription"
# [13] "DataCategory" "YearOfLastAssessment" "AssessmentFrequency"
# [16] "YearOfNextAssessment" "AssessmentType" "AdviceReleaseDate"
# [19] "AdviceCategory" "AdviceType" "UseOfDiscardsInAdvice"
# [22] "PABufferApplied" "TrophicGuild" "FisheriesGuild"
# [25] "SizeGuild" "Published" "GeneratedOn"
# [28] "SectionNumber"
# Note: OldStockCode is only available for 2017
tt <- rawsl[, c("StockCode", "OldStockCode", "Description", "ExpertGroup")]
write.csv(tt, file = "~/FileName.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment