Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learn more about F# at http://fsharp.net
- // See the 'F# Tutorial' project for more help.
- open FSharp.Data
- open System
- type Record = {voivoship : Option<int>; district : Option<int>; community:Option<int>; rozd:Option<int>; name: Option<string>; addinf: Option<string> }
- type InputXml = XmlProvider<"Terc.xml">
- [<EntryPoint>]
- let main argv =
- let createRecord =
- {
- voivoship = None
- district = None
- community = None
- rozd = None
- name = None
- addinf = None
- }
- let addCol name number string record =
- match name with
- | "WOJ" -> { record with voivoship = number }
- | "POW" -> { record with district = number }
- | "GMI" -> { record with community = number }
- | "RODZ" -> { record with rozd = number }
- | "NAZWA" -> { record with name = string }
- | "NAZDOD" -> { record with addinf = string }
- | _ -> record
- let tercs = InputXml.GetSample()
- let createRecordBasedOnRow cols =
- let rec iterateCols record (cols:List<InputXml.Col>) =
- match cols with
- | head::tail -> iterateCols (addCol head.Name head.Number head.String record) tail
- | [] -> record
- iterateCols createRecord cols
- let records =
- seq {
- for row in tercs.Rows do
- yield (createRecordBasedOnRow (row.Cols |> Array.toList))
- }
- for r in records do
- match r.voivoship with
- | None -> ()
- | Some s -> printfn "%i" s
- Console.Read();
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement