I have a text file with profanity word separated by comma (,). Now I have to create an array by reading this text file, each and every profanity word should be stored into t
Here is a jQuery + AJAX Solution that you can use
//HTML
//JavaScript/jQuery
$(function () {
//Stop caching if csv is likely to change often (change $.get to $.ajax)
$.ajaxSetup({
cache: false
});
$('#load').click(function () {
$.get($('#file').val(), function (content) {
var output = content.split(new RegExp(",|\r"))
.map(function (element) {
//Do what ever tidy up here
return $.trim(element).toLowerCase();
});
console.log(output);
});
});
});
Tested on CSV from http://en.wikipedia.org/wiki/Comma-separated_values
You could hide the file input control by using something like this http://plugins.jquery.com/project/custom-file