Created
January 30, 2015 17:47
-
-
Save fitnr/00c515a5104f74de37d4 to your computer and use it in GitHub Desktop.
convert table to csv (uses JQuery)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// encoded: | |
// javascript:(function()%7B$('table').each(function()%7Bvar%20$table=$(this);$('%3Ctextarea%3E').css('width',$table.width()).css('height','400px').html($.map($table.find('tr'),function(tr)%7Breturn%20$.map($(tr).find('th,%20td'),function(e)%7Breturn'%22'+$(e).text().replace('%22','%22%22').replace('%5Cn','%20')+'%22'%7D).join(',')%7D).join('&%2313;&%2310;')).insertAfter($table);%7D)%7D)() | |
javascript:(function() { | |
$('table').each(function() { | |
var $table = $(this); | |
$('<textarea>').css('width', $table.width()) | |
.css('height', '400px') | |
.html( | |
$.map( | |
$table.find('tr'), function(tr) { | |
return $.map($(tr).find('th, td'), function(e) { | |
return '"' + $(e).text().replace('"', '""').replace('\n', ' ') + '"' | |
}).join(',') | |
}).join(' ')) | |
.insertAfter($table); | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment