2014-04-26 32 views
0

我有一个表有很多列,我可以转换此表来表示相同的信息,但列标题放在行。例如试图将此表格转换:模板转换/转置表列 - >行

{| class="wikitable" 
! scope="col"| Benchmark 
! scope="col"| Total number of transactions 
! scope="col"| Device data reads (DMA) 
! scope="col"| Device data writes (DMA) 
! scope="col"| Uncacheable data reads   
! scope="col"| Uncacheable data writes   
! scope="col"| Uncacheable instruction fetches 
! scope="col"| Data read transactions   
! scope="col"| Data read misses    
! scope="col"| Data read hit-ratio    
! scope="col"| Instruction fetch transactions 
! scope="col"| Instruction fetch misses  
! scope="col"| Instruction fetch hit-ratio  
! scope="col"| Data write transactions   
! scope="col"| Data write misses    
! scope="col"| Data write hit-ratio    
! scope="col"| Copy-back transactions 
|- 
! scope="row"| Vortex 
| 572369 
| 0 
| 0 
| 0 
| 0 
| 0 
| 193418 
| 43473 
| 77.52% 
| 261195 
| 103199 
| 60.49% 
| 117756 
| 83646 
| 28.97% 
| 0 
|- 
! scope="row"| Equake 
|482932 
|0 
|0 
|0 
|0 
|0 
|128014 
|16909 
|86.79% 
|281793 
|58486 
|79.25% 
|73125 
|14086 
|80.74% 
|0 
|- 
! scope="row"| Parser 
|571505 
|0 
|0 
|0 
|0 
|0 
|224470 
|26972 
|87.98% 
|224082 
|14404 
|93.57% 
|122953 
|50771 
|58.71% 
|0 
|} 

成类似:

{| class="wikitable" 
! scope="col"| Benchmark 
! scope="col"| Vortex 
! scope="col"| Equake 
! scope="col"| Parser 
|- 
. 
. 
. 

有没有可能是一个模板能做到这一点?

回答

2

你想转换整个表?在MediaWiki中没有内置函数,我怀疑为它创建模板会很麻烦(除非你使用Lua)。如果这只是偶尔发生的需求,我会简单地将表复制/粘贴到LibreOffice Calc/Excel /等,转置在那里,然后重新创建表。

如果您需要定期自动执行此操作,请查看Scibuntu扩展程序和Lua,然后再询问是否卡住!

如果您对JavaScript解决方案感到满意,那么您已经有几个SO问题了。 Convert TD columns into TR rows

+0

谢谢你,我也看着这些,但我希望会有一些MediaWiki的做到这一点。 – Joelmob

1

您可以使用模板做一次性:假设您有一个或两个表格要维护两个版本之间的转换。

我会提出了一个例子,在en.wikipedia.org/User:Rich Farmbrough /转

+1

请在这里添加答案或只是发表一些说明,而不仅仅是发布链接。 –

+0

我看了这个例子,但我认为这看起来很复杂,这需要一个新的模板,每个这样的表可以调换,但也许可以改进。 – Joelmob