Created
January 22, 2024 21:11
-
-
Save jkone27/7cecb087b4b7502306789cc1834faf0d to your computer and use it in GitHub Desktop.
Print in a table a google sheet published as csv with spectre console and fsharp data csv provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: FSharp.Data" | |
#r "nuget: EluciusFTW.SpectreCoff" | |
open FSharp.Data | |
open SpectreCoff | |
type ``💁`` = | |
// just create your own google sheet and publish it from File menu, select CSV | |
// or use any other CSV, this works with any valid csv published in url or in your file system | |
CsvProvider<"https://docs.google.com/spreadsheets/d/e/GOOGLEKEYBLABLABLABLABLA/pub?output=csv"> | |
let sample = ``💁``.GetSample() | |
let columns = | |
sample.Headers | |
|> Option.toList | |
|> Seq.collect (fun x -> x) | |
|> Seq.map (fun h -> column (Calm h)) | |
|> Seq.toList | |
let rows = | |
sample.Rows | |
|> Seq.map (fun r -> Strings [ r.One; r.Two.ToString(); r.Three; r.Four ]) | |
|> Seq.toList | |
let powerTable = table columns rows | |
powerTable |> toOutputPayload |> toConsole |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment