                 let csvText = try String(contentsOf: localPathURL, encoding: encodingType);
                 
                 // Check the csv count
-                if csvText.count > 0 {
+                if csvText.length > 0 {
                     
                     // Split based on Newline delimiter
-                    let csvArray = self.splitUsingDelimiter(csvText, separatedBy: "\n") as NSArray
+                    //let csvArray = self.splitUsingDelimiter(csvText, separatedBy: "\n") as NSArray
+                    let csvArray = csvText.lines
                     if csvArray.count >= 2 {
                         var fieldsArray:NSArray = [];
                         let rowsArray:NSMutableArray  = NSMutableArray()
+                        let div = self.getDividerCharacter()
                         for row in csvArray {
                             // Get the CSV headers
-                            if((row as! String).contains(csvArray[0] as! String)) {
-                                fieldsArray = self.splitUsingDelimiter(row as! String, separatedBy: divider?.rawValue ?? ",") as NSArray;
+                            if(row.contains(csvArray[0])) {
+                                fieldsArray = self.splitUsingDelimiter(row, separatedBy: div) as NSArray;
                             } else {
                                 // Get the CSV values
-                                let valuesArray = self.splitUsingDelimiter(row as! String, separatedBy: divider?.rawValue ?? ",") as NSArray;
+                                let valuesArray = self.splitUsingDelimiter(row, separatedBy: div) as NSArray;
                                 if valuesArray.count == fieldsArray.count  && valuesArray.count > 0{
                                     let rowJson:NSMutableDictionary = self.generateDict(fieldsArray, valuesArray: valuesArray)
                                     if rowJson.allKeys.count > 0 && valuesArray.count == rowJson.allKeys.count && rowJson.allKeys.count == fieldsArray.count {

//MARK: -  Export public Methods

///a free function to make export the CSV file from file name, fields and values
public func exportCSV(_ filename:String, fields: NSArray, values: NSArray) -> String{
    return CSVExport.export.exportCSV(filename, fields: fields, values: values);
}

        return Static.instance
    }
    
    // Get Divider character
    func getDividerCharacter( ) -> String {
        return divider?.rawValue ?? ",";
    }
    
    ///a free function to make read the CSV file
    open func readCSV(_ filePath:String) -> NSMutableDictionary{
        return CSVExport.export.read(filepath: filePath);
    }
    
    ///a free function to convert from NSMutableDictionary to CSV object
    open func converToObject(_ fileDetails:NSMutableDictionary) -> CSV{
        let csvObj = CSV()
        if fileDetails.allKeys.count > 0 {
            let keys:[String] = fileDetails.allKeys as! [String]
            for key in keys  {
                switch key {
                case "fields":
                    let fieldValue = fileDetails.object(forKey: key) as! NSArray
                    csvObj.fields = fieldValue
                    break
                case "rows":
                    let fieldValue = fileDetails.object(forKey: key) as! NSArray
                    csvObj.rows = fieldValue
                    break
                case "name":
                    let fieldValue = fileDetails.object(forKey: key) as! String
                    csvObj.name = fieldValue
                    break
                case "divider":
                    let fieldValue = fileDetails.object(forKey: key) as! String
                    csvObj.delimiter = fieldValue
                    break
                default:
                    break
                }
            }
        }
        return csvObj;
    }
    
    ///a free function to make read the CSV file
