Csv file editing

Help me,

I have a csv file with following fields:

sim	  name1	name2	name3	name4	name5	count
file1	        0.1	  0.2   	0.3	          0.4	0.5	
file2	0.1	 0.2	        0.3	          0.4	0.5	
file3	0.1	 0.2	        0.3	          0.4	0.5	
file4	0.1	0.2	        0.3	          0.4	0.5	
file5	0.1	0.2	        0.3	          0.4	0.5	

i need to get the count if the value of the row is >0.3. i.e. for example in the count column it has to show 2,2,2,2,2 . help me code this on shell.

Thanks,
Arun.

What have you tried?

Hi Arun,
Welcome to the UNIX.com forums.

Whenever you start a thread here, it always helps us if you tell us what operating system and shell you're using. Various systems and shells have many similar, but not always identical tools and options. If we don't know what shell and operating system you're using, we are likely to make suggestions that will not work in your environment.

Please also show us what you have tried, what errors you are getting, what output you're getting, and tell us where you are stuck. We are here to help you learn how to do things for yourself; not to act as your unpaid programming staff.

When you say you're using a csv file, that can mean several things. Usually, it is a file containing fields that are separated by a comma. Sometimes it is a file containing fields that are separated by some other single character such as a <tab>, a <colon>, a <semicolon>, or some other single character. The sample data you've shown us seems to use a <tab> character to separate some fields and a <tab> and a varying number of <space>s for other fields. We need a clear description of what file format you are actually using.

You also need to clearly describe the output you are trying to produce. Saying that the count field should be 2,2,2,2,2 seems to be saying that you want each line of output to contain identical data that indicates the number of data points in each column that contains a value greater than .3, but that doesn't match the sample data you have supplied. Please clearly describe, in English, what the data in the count field should be for each input line AND please show us the exact output that you hope to produce from the sample input file you have supplied (in CODE tags).

Note also that if every line of input in your sample data has identical data in the fields that are being investigated, it makes it hard to know if any code that we might write for you is actually performing the checks you want to perform.

Please help us help you.

Hi Thanks for the reply but I am very new to use linux and scripting, so i have no idea about it.

Thanks,
Arun

--- Post updated at 04:44 PM ---

The file i have is a comma separated values. The output required is:

sim    count>0.3
file1    2
file2    2
file3    2
file4    2

...................

If you can't:

  • tell us what version of Linux you're using,
  • what shell you're using,
  • show us sample data that matches your specified input file format, and
  • clearly describe the output you're trying to produce,

then there isn't much hope that we'll guess correctly at what you really want. Note that you say your sample input file is a csv file using <comma> as the field separator, but you sample input does not contain even one <comma> character.

Are you asking us to complete a homework assignment for you?

hello thanks for bearing with me and sorry for posting this question. you can delete this request. sorry again for wasting your time

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.