Computing.Net > Forums > Programming > Extracting a set of lines from a text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extracting a set of lines from a text file

Reply to Message Icon

Name: nachikethas
Date: May 13, 2009 at 02:14:33 Pacific
OS: Linux i686
Subcategory: General
Comment:

i have a file which look like thus

6 LYS C ?? 999.99 162.37 999.99 -109.28 139.83 -38.02 153.04
7 GLU P Ek -54.40 139.07 176.99 -85.05 -144.26 76.54 999.99
8 LEU E Ck -112.25 149.56 177.92 -54.05 178.76 999.99 999.99
9 VAL E Cl -132.21 157.54 171.95 -71.37 999.99 999.99 999.99
10 LEU E Dk -103.69 137.65 176.45 161.64 64.30 999.99 999.99
11 ALA C Ej -74.49 116.45 173.99 999.99 999.99 999.99 999.99
12 LEU C Df -83.25 -20.95 177.33 -47.38 169.11 999.99 999.99
13 TYR C Bl -145.88 160.42 -176.71 -55.08 -86.79 999.99 999.99
14 ASP P Ek -65.38 145.53 169.48 -82.34 10.88 999.99 999.99


i want to extract the lines based on the 1st column.say c7-10 shld give me all the lines including 7 and 10
and there are white space in the 1st column



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: May 13, 2009 at 02:36:11 Pacific
Reply:

if you have Python, here's an alternative solution

for n,line in enumerate(open("file")):
    if n>=5 and n <=9 :
        print line   


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Extracting a set of lines from a text file

To cut and paste a set of lines from a file www.computing.net/answers/programming/to-cut-and-paste-a-set-of-lines-from-a-file/20198.html

delete x number of lines from a CSV file www.computing.net/answers/programming/delete-x-number-of-lines-from-a-csv-file/19820.html

batch extract lines from files www.computing.net/answers/programming/batch-extract-lines-from-files/16749.html