Skip to content

Instantly share code, notes, and snippets.

@jonas1ara
Forked from jkone27/sheetCsvSpectre.fsx
Created January 24, 2024 23:56
Show Gist options
  • Save jonas1ara/a08094d7aadda393c22287bb27f191c9 to your computer and use it in GitHub Desktop.
Save jonas1ara/a08094d7aadda393c22287bb27f191c9 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
#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