Csv file editing


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Csv file editing
# 1  
Old 02-05-2019
Csv file editing

Help me,

I have a csv file with following fields:

Code:
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.

Last edited by vgersh99; 02-05-2019 at 11:23 AM.. Reason: Code tags, please!
# 2  
Old 02-05-2019
What have you tried?
# 3  
Old 02-05-2019
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.
# 4  
Old 02-05-2019
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:

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

...................
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input files, sample output files, and code segments.

Last edited by Don Cragun; 02-05-2019 at 12:54 PM..
# 5  
Old 02-05-2019
Quote:
Originally Posted by vinnu0154
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:

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

...................
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input files, sample output files, and code segments.
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?

Last edited by Don Cragun; 02-05-2019 at 01:04 PM.. Reason: Add note.
# 6  
Old 02-05-2019
hello thanks for bearing with me and sorry for posting this question. you can delete this request. sorry again for wasting your time
# 7  
Old 02-05-2019
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies

2. Shell Programming and Scripting

Save output of updated csv file as csv file itself

Hi, all I want to sort a csv file based on timestamp from oldest to newest and save the output as csv file itself. Here is an example of my csv file. test.csv SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0739.JPG,2015:02:17 11:32:21 /home/intannf/foto/IMG_0749.JPG,2015:02:17 11:37:28... (10 Replies)
Discussion started by: refrain
10 Replies

3. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

4. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

5. Shell Programming and Scripting

Compare 2 csv files in ksh and o/p the difference in a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 The... (7 Replies)
Discussion started by: Naresh101
7 Replies

6. Shell Programming and Scripting

Comparing 2 CSV files and sending the difference to a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 ... (1 Reply)
Discussion started by: Naresh101
1 Replies

7. Shell Programming and Scripting

csv file editing using KSH

I'm trying to write a shell script to extract useful fields in a csv file and copy them to a new file: the input file is as below when opened using notepad++: //////////////////////////////////////////////////////////// ZZZZZZZZZZZZZZZZZZZZZZ ,"A", , , ,24,18,0,0,42,0 , ,B, ,... (1 Reply)
Discussion started by: zekruss
1 Replies

8. Shell Programming and Scripting

2 problems: Mailing CSV file / parsing CSV for display

I have been trying to find a good solution for this seemingly simple task for 2 days, and I'm giving up and posting a thread. I hope someone can help me out! I'm on HPUX, using sqlplus, mailx, awk, have some other tools available, but can't install stuff that isn't already in place (without a... (6 Replies)
Discussion started by: soldstatic
6 Replies

9. Shell Programming and Scripting

Need to compare two csv files values and write into another csv file

Hi all, Am new to scripting. So i just need your ideas to help me out. Here goes my requirement. I have two csv files 1.csv 2.csv abc,1.24 abc,1 def,2.13 def,1 I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
Discussion started by: chinnahyd
2 Replies
Login or Register to Ask a Question