Skip to content

Instantly share code, notes, and snippets.

@simonced
Last active June 13, 2017 05:54
Show Gist options
  • Save simonced/aacba5a0c141556b2edc87bed2bddd23 to your computer and use it in GitHub Desktop.
Save simonced/aacba5a0c141556b2edc87bed2bddd23 to your computer and use it in GitHub Desktop.
org mode table data rotate format with js source-block

Thanks to this little JS source-block snippet, I could simply rotate a 3 rows table into a 3 column table.
JS because I have no clue how to achieve the same with e-lisp.

My real world problem had waaaaay more columns, hence the need to automate the thing!

#+name: data_table
タイトル1タイトル2タイトル3タイトル4
Title1Title2Title3Title4
123456789546
#+BEGIN_SRC js :var data=data_table :results table :exports both
var output = [];
for(var column=0; column<data[0].length; ++column) {
	output.push( [ data[0][column], data[1][column], data[2][column] ] );
}
return output;
#+RESULTS:
タイトル1Title1123
タイトル2Title2456
タイトル3Title3789
タイトル4Title4546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment