     }
     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
-}
+    let result=csvFile(data: done, header: y[0].componentsSeparatedByString(","))
+    return result
+}
+
 
 func write_csv(x:matrix, filename:String, prefix:String=S2_PREFIX){
     var seperator=","

        Swift.print("File probably wasn't recognized")
    }
}

    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")
