Skip to content

Instantly share code, notes, and snippets.

@RadGH
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RadGH/f30ca849f910a33e0060 to your computer and use it in GitHub Desktop.
Save RadGH/f30ca849f910a33e0060 to your computer and use it in GitHub Desktop.
Convert pasted Excel/Spreadsheet data to 2d array in JavaScript
// Converts a (user-pasted) string to a 2d array, utilizing line breaks and tabs.
function interpret_table( data ) {
var table = data.split("\n");
for (i in table) {
table[i] = table[i].split("\t");
}
return table;
}
@RadGH
Copy link
Author

RadGH commented Aug 20, 2014

Looks basic, but it's quite useful. See this fiddle for usage:

http://jsfiddle.net/fobwoL8e/2/

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