extracting portion of the files

I have many files as follows(input.txt) and i want to extract portion of it and want to save to another text file

# 
# XXX
# YYY
# ZZZ
# AAAAAA
# AAAAAA
# AAAAAAA AAAAA
# CCCCC
# EEEEE
# EEEEE
# DDDDD
# A(MN)  S(MN/SN)  D(MN/WN) FPR(OO/WW)   ER   QW   RRRR   WWWW   QQQQQ   XXXXX
#
45.0300  1.4212  1.1300  1.7716  5.0000  4.0000  0.0400  0.0100  1.0020  1.5000
85.0300  1.9235  1.9974  1.0492  5.0000  4.0000  0.0400  0.0100  1.0020  1.5000
56.0300  1.1454  1.1255  1.0902  5.0000  4.0000  0.0400  0.0100  1.0020  1.5000
78.0300  1.9434  1.0089  1.0528  5.0000  4.0000  0.0400  0.0100  1.0020  1.5000

I want to extract below file from the above file

1.1300  
1.9974
1.1255
1.0089

I tried

import pandas as pd
a=pd.read_csv("input.csv")
b=a.loc[12:15]

It doesnot work here. Hope experts may help me.Thanks.

>Solution :

A possible solution:

pd.read_csv('name_file.csv', comment='#', header=None, sep='\s+')[2]

Output:

0    1.1300
1    1.9974
2    1.1255
3    1.0089
Name: 2, dtype: float64

Leave a Reply