You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(with-temp-file"/tmp/insert-file-test.org"
(goto-char (point-max))
(insert"some text at the start #+NAME: test-table1 | a | b | c | |---+---+---| | 1 | 2 | 3 | | 2 | 4 | 6 | |---+---+---| | | | 9 | #+TBLFM: @>$>=vsum(@I..@II) some text at the end #+NAME: notable #+BEGIN_EXAMPLE Some Example #+END_EXAMPLE some other text at the start #+NAME: test-table2 #+caption: original caption of test-table2 #+ATTR_LATEX: :font \\footnotesize :placement [H] | a | b | c | |---+----+----| | 1 | 20 | 10 | | 2 | 40 | 20 | |---+----+----| | | | 30 | #+TBLFM: @>$>=vsum(@I..@II) some other text at the end"))
Test
a
b
c
1
20
10
2
40
20
30
a
b
c
1
20
10
2
40
20
30
TableFilter
(let ((lst (split-string vals)))
(concatenate'list (loop for row in tbl
if (member (let ((field (nth col row)))
(if (numberp field)
(number-to-string field)
field)) lst)
collect row into newtbl
;; else do (princ (format "%s: %s\n" (nth col row) lst))
finally return newtbl)))
Test
Name
A
B
Peter
1
10
Paul
2
20
Mary
3
30
Peter
4
40
Mary
5
50
Peter
6
60
Name
A
B
Peter
1
10
Paul
2
20
Peter
4
40
Peter
6
60
lobTableFilterRe
(let ((lst (split-string vals)))
(concatenate'list (loop for row in tbl
if (let* ((rawfield (nth col row))
(field (if (numberp rawfield)
(number-to-string rawfield)
rawfield)))
(loop for regx in lst
when(string-match-p regx field) return 't
finally return nil))
collect row into newtbl
;; else do (princ (format "%s: %s\n" (nth col row) lst))
finally return newtbl)))
Test
Name
A
B
aa
for mu3e
10
bb
belongs to MEG.
20
cc
has its own account
30
dd
another item for mu3e experiment
40
ee
for own group
50
ff
another one for MEG exp
60
Name
A
B
aa
for mu3e
10
bb
belongs to MEG.
20
dd
another item for mu3e experiment
40
ff
another one for MEG exp
60
GroupTable
importpandasaspdimportnumpyasnpimportorgbabelhelperasobhimportsysimportredf=obh.orgtable_to_dataframe(tbl)
grparr=re.split(r",\s*", grp)
#print re.split(r",\s*", rescols) + [grp]df=df[re.split(r",\s*", rescols) +grparr]
forelemingrparr:
assertelemindf.columns, "Error: group column %s not in table columns %s"% (elem, ",".join(df.columns))
ifop=="sum":
res=df.groupby(grparr).sum()
else:
error("operation %s not implemented"%op)
sys.exit(1)
print(obh.dataframe_to_orgtable(res))
Test
Name
Year
A
B
Peter
2018
1
10
Paul
2018
2
20
Mary
2018
3
30
Peter
2019
4
40
Paul
2019
5
50
Mary
2019
5
60
Peter
2019
6
70
Name
B
Mary
90
Paul
70
Peter
120
Year
Name
B
2018
Mary
30
2018
Paul
20
2018
Peter
10
2019
Mary
60
2019
Paul
50
2019
Peter
110
ExportOneTableToExcel
Function to write a single table TBL to an Excel file FNAME.
Function to write several tables to different sheets in the same
Excel file FNAME. The table names are given as a string TBLNAMES
containing the comma separated list of table names. The sheet name
is given in SHEET.
Here I use a method copied from the org-sbe implementation where
a particular source block is called by executing
org-babel-execute-src-block on a constructed source block info
structure, where the call is given as part of that source block’s
:var definition.