     var columns:Int = 0
     var startrow:Int = 0    //The first row of the data
     var categorical_col:[Int]=[]    //Record the columns which are categorical variables
-    if(header==true)
+    if(skip_header==true)
     {
         startrow = 1
     }
-    let test = y[detectRow + startrow - 1].componentsSeparatedByString(",") //Use first row to detect which columns are categorical
+    let test = y[completeDataRow + startrow - 1].componentsSeparatedByString(",") //Use first row to detect which columns are categorical
     categorical_col = Array(count:test.count, repeatedValue:-1)
     columns=0
     for testtext in test{

    }
    var done = zeros((rows-startrow, columns))
    done.flat.grid = array
    return done
}

func read_csv_header(filename:String) -> [String]{
    var x: String?
    do {
        x = try String(contentsOfFile: filename, encoding: NSUTF8StringEncoding)
    } catch _ {
        x = nil
    }
    x=x!.stringByReplacingOccurrencesOfString("\r\n",withString: "\n")  //Remove \r if \r\n
    x=x!.stringByReplacingOccurrencesOfString("\r",withString: "\n")  //Change \r if there is any
    var y = x!.componentsSeparatedByString("\n")
    var header:[String] = []
    header=y[0].componentsSeparatedByString(",")
    return header
}

func write_csv(x:matrix, filename:String, prefix:String=S2_PREFIX){
    var seperator=","

    return done
}*/

class csvFile{
    var data: matrix
    var header: [String]
    init(data: matrix, header: [String]){
        self.data = data
        self.header = header
    }
}

func read_csv(filename:String, _ skip_header:Bool=true, _ completeDataRow: Int=1) -> csvFile{
    var x: String?
    do {
        x = try String(contentsOfFile: filename, encoding: NSUTF8StringEncoding)
    } catch _ {
        x = nil
    }
    //There are three types of line breaks: \r, \n and \r\n. All change to \n.
    x=x!.stringByReplacingOccurrencesOfString("\r\n",withString: "\n")  //Remove \r if \r\n
    x=x!.stringByReplacingOccurrencesOfString("\r",withString: "\n")  //Change \r if there is any
    var y = x!.componentsSeparatedByString("\n")
