Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NuGet download stats
#I @"packages\Nuget.Core.2.8.3\lib\net40-Client"
#r "NuGet.Core.dll"
#r "System.Xml.Linq.dll"
let repository =
NuGet.PackageRepositoryFactory.Default.CreateRepository
"https://nuget.org/api/v2"
type NuGetStat =
{ Id: string; DownloadCount:int}
let packages =
query {
for p in repository.GetPackages() do
where (
p.Title.Contains "Fsharp" ||
p.Title.Contains "FSharp" ||
p.Title.Contains "fsharp" ||
p.Title.Contains "F#" ||
p.Tags.Contains "fsharp" ||
p.Tags.Contains "F#" ||
p.Tags.Contains "f#")
select p
}
|> Seq.toArray
let fsharp =
packages
|> Seq.filter (fun p ->
let s = if p = null || p.Title = null then "" else p.Title.ToLowerInvariant()
let pos = s.IndexOf("fsharp")
if pos<=0 then true else not <| System.Char.IsLetter(s.[pos-1])
)
|> Seq.groupBy (fun p -> p.Id)
|> Seq.map (fun (key, packages) ->
{Id=key;
DownloadCount = (packages |> Seq.maxBy (fun x->x.DownloadCount)).DownloadCount})
|> Seq.sortBy (fun x -> -x.DownloadCount)
|> Seq.toArray
#load @"packages\Deedle.1.0.6\Deedle.fsx"
open Deedle
let frame = Frame.ofRecords fsharp
frame.SaveCsv("d:\\nuget_fsharp.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment