Skip to content

Instantly share code, notes, and snippets.

@adacola
Created April 12, 2017 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adacola/e6fa75c1b9e5d8c24e4f00b7e4ee50e0 to your computer and use it in GitHub Desktop.
Save adacola/e6fa75c1b9e5d8c24e4f00b7e4ee50e0 to your computer and use it in GitHub Desktop.
twiplaの参加者一覧のTSVファイルを作成します
(*
twiplaの参加者一覧のTSVファイルを作成します。
使用方法
twiplaの印刷用ページを表示してページ全体をクリップボードにコピーし、その内容を文字列にしてtwiplaToTsvの引数に渡します。
*)
open System
let twiplaToTsv (content : string) =
let header = "twitter ID\t名前\tDM済みかどうか\t支払い方法\t支払い詳細通知済みかどうか\t支払い済みかどうか"
content.Split([|"\r\n"; "\n"; "\r"|], StringSplitOptions.None) |> Seq.skipWhile ((<>) "【参加者リスト】") |> Seq.skip 2
|> Seq.chunkBySize 2 |> Seq.choose (function
| [| first; second |] -> sprintf "%s\t%s" (first.Split('\t').[1]) (second.Split('\t').[0]) |> Some
| [| "" |] -> None
| otherwise -> failwithf "エラー発生。以下の行が不正です : %A" otherwise)
|> String.concat "\r\n"
|> printfn "%s\r\n%s" header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment