Find the answer to your Linux question:
Results 1 to 5 of 5
I have this data compose of two columns: 0 2.45566 1 2.46678 0 2.47667 1 2.48778 0 2.49638 0 2.49767------ 1 2.50990 what i want to do is getting rid ...
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    3

    how to select columns and rows from a text file

    I have this data compose of two columns:

    0 2.45566
    1 2.46678
    0 2.47667
    1 2.48778
    0 2.49638
    0 2.49767------
    1 2.50990

    what i want to do is getting rid of rows which repeat each other on the first column. For example i want to delete 6th row due to there is 0 after a 0.

    once i delete the row ( which has dashes next to it) i will have

    0 2.45566
    1 2.46678
    0 2.47667
    1 2.48778
    0 2.49638
    1 2.50990


    so yeah i want to write sth with awk or sed i don know just to get rid of all repetitive rows like that.

    raw study
    awk '{chaine=substr($0,2,1);if (chain(i)==chain(i+1)) print $0}' data.txt
    its supposed to be sth like that additional with a for loop addition

    so i will say

    for i 1 to end of rows ( work in 1st column)
    if the value of ith row in the first column == i+1 th value
    then delete i+1 th row..
    end

    Thanks a lot..

  2. #2
    Just Joined!
    Join Date
    Mar 2005
    Location
    Corona, CA
    Posts
    29
    I think uniq will do what you want, it can remove duplicates.

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    3
    but how am i gonna select only first column? there is no duplication in the second column...

    Thanks,

  4. #4

  5. #5
    Just Joined!
    Join Date
    Aug 2010
    Posts
    3
    It s still not workin shud i use python instead?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...