NetFlix Data with F# Part I

by Lord Cod3n 22. April 2009 07:09

Here is my first interactive attempt to work with the Netflix files.  I have attempted this before in C# , but ran out of free time.  Here is my F# code with comments on what I am attempting to do.

//We need to read files from disk

open System.IO

//Open the file and assign it to the file variable


let file = File.OpenText("c:\\SRC_Local\\SampleData\\download\\training_set\\training_set\\mv_0000001.txt")

//Read the whole file in a string

let contents = file.ReadToEnd()

//Here is where my functional side and imperative side start to battle a little

//first split the file by carriage return line feed

let data =
    contents.Split(System.Environment.NewLine.ToCharArray())

//Next split each line by ;


let data2 =
    data
    |>Seq.map(fun i -> i.Split([|';'|]))

//Skip the first item

let data3 =
    data
    |> Seq.skip(1) 

I am going to poke around some more and will post up part II when i get something interesting.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

William Moore is the lead Software Architect and Technologist for Coden Enterprises. He has more than a decade of software development experience primarily Microsoft Platforms.  William enjoys the full gamit of coding everything from the UI down to the database.

Most comments

Page List