转换/转置表格列 -> 行的模板

问题描述 投票:0回答:2

我有一个包含许多列的表格,我可以转换该表格以表示相同的信息,但将列标题放置在行中。尝试转换此表的示例:

{| 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
|-
.
.
.

模板可以做到这一点吗?

mediawiki wikipedia
2个回答
2
投票

您想要调换整个表格吗? MediaWiki 中没有内置的函数,我怀疑为此创建一个模板是否值得(除非您使用 Lua)。如果这种需求只是偶尔发生一次,我只需将表格复制/粘贴到 LibreOffice Calc/Excel/etc 中并进行转置,然后重新创建表格。

如果您需要定期自动执行此操作,请查看 Scibuntu 扩展和 Lua,如果您遇到困难,请再次询问!

如果您对 JavaScript 解决方案感到满意,那么已经有一些问题了,请参阅例如将 TD 列转换为 TR 行


2
投票

您可以使用模板一次性完成:假设您有一个或两个表,您想要在其中维护两个版本,并相互转置。

我将在 en.wikipedia.org/User:Rich Farmbrough/transpose 上举一个例子

© www.soinside.com 2019 - 2024. All rights reserved.