我有一个文本文件,它有一些标题行和一些列(数字)。 我想跳过标题来阅读这个文件,然后选择一些列并 使用Python脚本在新文件中编写它们。在
例如,让我们调用in_table.txt
下面的数据。
我想跳过页眉(也就是空白行),
然后选择第一列和第四列(仅限数值)
并将它们保存在一个新文件out_table.txt
中,没有标题,只有数字。
如何使用Python脚本实现这一点?在
非常感谢!!在
在_表格.txt公司名称:
hline1 hline1 hline1
hline2 hline2 hline2
hline3 hline3 hline3
par1 par2 par3 par4 par5
1. 10. 100. 1000. 10000.
2. 20. 200. 2000. 20000.
3. 30. 300. 3000. 30000.
4. 40. 400. 4000. 40000.
5. 50. 500. 5000. 50000.
一。在
如果您坚持使用空格分隔符,请使用
CSV
如果你用逗号分隔,你很可能会在
^{pr2}$csv
库中内置Python或者更简洁一点
相关问题 更多 >
编程相关推荐