csv Python 中第 header 列的文本合并
Text Merging for column header in Python for csv
我想创建一个 csv 文件,其中前 2 行专用于标题,其余是每一行的列 header,是否可以在 Python 中以编程方式实现?
我尝试在 xlsxwriter
official docs but nothing good came out. Had it been single header and single column thing I have already done it using python CSV module 中搜索关键字 text merging
和 column header concatenation
。
例如
_________________________________________________________
|____Big_Heading_1______|_____Big_Heading_2_______|_____|
|SH_1_|__SH_2_|__SH_3___|_SH_1_|__SH_2_|__SH_3____|_SH1_|
|D1 | D2 | D4 | D5 | D6 | D7 | D8 |
|D9 | D10 | D11 | D12 | D13 | D14 | D15 |
符号:SH = Small Heading, D = Data
注意:代替第三个 Big Heading
的地方没有那个特定的东西没有 Big Heading
即。 Big Heading
等于 Small Heading
.
谢谢。
尝试在 xlsxwriter 中使用 merged cells。
稍微好一点的方法是使用 pandas 。通过这种方式,您可以创建一个数据框并让 to_excel()
方法处理导出。
我想创建一个 csv 文件,其中前 2 行专用于标题,其余是每一行的列 header,是否可以在 Python 中以编程方式实现?
我尝试在 xlsxwriter
official docs but nothing good came out. Had it been single header and single column thing I have already done it using python CSV module 中搜索关键字 text merging
和 column header concatenation
。
例如
_________________________________________________________
|____Big_Heading_1______|_____Big_Heading_2_______|_____|
|SH_1_|__SH_2_|__SH_3___|_SH_1_|__SH_2_|__SH_3____|_SH1_|
|D1 | D2 | D4 | D5 | D6 | D7 | D8 |
|D9 | D10 | D11 | D12 | D13 | D14 | D15 |
符号:SH = Small Heading, D = Data
注意:代替第三个 Big Heading
的地方没有那个特定的东西没有 Big Heading
即。 Big Heading
等于 Small Heading
.
谢谢。
尝试在 xlsxwriter 中使用 merged cells。
稍微好一点的方法是使用 pandas to_excel()
方法处理导出。