python-3.x - 如何从表、.txt 文件、Python 3 中提取特定数据
问题描述
我想从保存为 .txt 文件的表中提取 2 列(输入和姓氏)的数据,然后生成包含两列(输入和姓氏)的输出文件(通过编写脚本)。我知道如何使用普通行来做到这一点,但不知道从哪里开始使用表格格式。
示例表 -
输入 | 姓名 | 中间名字 | 姓 | 性别 |
---|---|---|---|---|
123 | 山姆 | 米切尔 | 授予 | 男性 |
123 | 萨缪尔 | 不适用 | 菲努斯 | 男性 |
123 | 沙龙 | 伊丽莎白 | 格雷森 | 女性 |
实际数据 -
Input Input Type MGI Gene/Marker ID Symbol Name Feature Type
GO:0003723 Gene Ontology (GO) MGI:87879 Aco1 aconitase 1 protein coding gene
GO:0003723 Gene Ontology (GO) MGI:88022 Ang angiogenin, ribonuclease, RNase A family, 5 protein coding gene
GO:0003723 Gene Ontology (GO) MGI:88042 Apex1 apurinic/apyrimidinic endonuclease 1 protein coding gene
表的第二行从 GO:0003723 开始,每个新行也以 GO:0003723 开始。
解决方案
推荐阅读
- selenium - 元素必须是用户可编辑的,以便清除它在 selenium 中的异常
- elasticsearch - 嵌套对象上的弹性搜索复杂布尔查询的错误结果
- python - 抓取网站来源并搜索单词
- java - 弹簧值:不正确的显示字段
- security - Symfony4 防火墙注销
- javascript - 如何在不拉伸整个表格行的情况下将大量内容固定到表格单元格中
- java - Windows 在哪里保存 JDK 位置参考?
- mysql - MySQL 将表复制到另一个数据库(不在同一个网络)- 备份?
- vba - 循环文件路径并打开 excel 时出现运行时错误 9
- hibernate - 从两个表中检索数据有 mapid 注释