Skip to content

Instantly share code, notes, and snippets.

@williamhogman
Created October 9, 2011 20:03
Show Gist options
  • Select an option

  • Save williamhogman/1274084 to your computer and use it in GitHub Desktop.

Select an option

Save williamhogman/1274084 to your computer and use it in GitHub Desktop.
JavaScript CSV Parser
String.prototype.parseCSV = function(delim){
return this.split("\n").map(function(r){return r.split((delim || ","))});
}
@williamhogman
Copy link
Author

It ended up as a one liner. I looked it up and Array.map has as good support as forEach so I figured we could go with it @dindresto's implementation does quoting something that this version doesn't do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment