简体   繁体   English

如何从python中的文本文件中提取列

[英]how to extract columns from text file in python

I want to isolate a column in texte file I don't know how to do this.我想隔离texte文件中的一列,我不知道该怎么做。

I have this TXT code with units different but, sometimes I have units in double or more :我的TXT代码的单位不同,但有时我的单位是两倍或更多:

5g8hj;Tournevis;cm;5,10
6r9tl;Marteau;cm;8,20
5d6ft;peinture;l;50,10
7ja3t;Vis 12*12,25;cm;500,001
2gh6t;Clé BTR;mm;25,15
56ml1;Scie;m2;65,12
12654;Pince;m;12*12,12
56ml1;Scie à bois;m2;65,12
12654;Planche;m;12*12,12

So I want to extract and print in another file for example test_unit.txt this :所以我想提取并打印在另一个文件中,例如test_unit.txt:

cm
l
cm
cm
mm
m2
m
m2
m

How do that in python script如何在python脚本中做到这一点

I want to isolate a column in texte file I don't know how to do this.我想隔离texte文件中的一列,我不知道该怎么做。

I have this TXT code with units different but, sometimes I have units in double or more :我的TXT代码的单位不同,但有时我的单位是两倍或更多:

5g8hj;Tournevis;cm;5,10
6r9tl;Marteau;cm;8,20
5d6ft;peinture;l;50,10
7ja3t;Vis 12*12,25;cm;500,001
2gh6t;Clé BTR;mm;25,15
56ml1;Scie;m2;65,12
12654;Pince;m;12*12,12
56ml1;Scie à bois;m2;65,12
12654;Planche;m;12*12,12

So I want to extract and print in another file for example test_unit.txt this :所以我想提取并打印在另一个文件中,例如test_unit.txt:

cm
l
cm
cm
mm
m2
m
m2
m

How do that in python script如何在python脚本中做到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM