need to get single column form csv file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users need to get single column form csv file
# 1  
Old 07-20-2010
Java need to get single column form csv file

hi 2 all

i need to get single column from one csv file

anyone help me !
Code:
>cat file.csv 
name,age
x,1
y,2
z,3

Moderator's Comments:
Mod Comment Use code tags please, ty.


in this "file.csv" file i need only name column

can u help me !SmilieSmilie

Last edited by zaxxon; 07-20-2010 at 04:26 AM.. Reason: code tags
# 2  
Old 07-20-2010
Check out the man page of the cut command and try it out. If you get stuck do not hesitate to ask here again.
# 3  
Old 07-20-2010
Java

is there any direct cmd to get single column ???/
# 4  
Old 07-20-2010
Using a loop...

Code:
while IFS=, read NAME  rest_of_line; do
  echo $NAME
done < file.csv

Fine, if you don't have many columns.

Otherwise cut is probably the best option.
# 5  
Old 07-20-2010
Code:
[house@leonov] cat data
x,1
y,2
z,3
[house@leonov] awk -F ',' '{print $1}' data
x
y
z

# 6  
Old 07-20-2010
Quote:
Originally Posted by ponmuthu
is there any direct cmd to get single column ???/
What is the problem trying out cut?
# 7  
Old 07-20-2010
thank you dr.house
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get maximum per column from CSV file, based on date column

Hello everyone, I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this: 20170628-23:25:01,1,0,0,1,1,1,1,55,55,1 20170628-23:30:01,1,0,0,1,1,1,1,56,56,1 20170628-23:35:00,1,0,0,1,1,2,1,57,57,2 20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies

2. Shell Programming and Scripting

Paste 2 single column files to a single file

Hi, I have 2 csv/txt files with single columns. I am trying to merge them using paste, but its not working.. output3.csv: flowerbomb everlon-jewelry sofft steve-madden dolce-gabbana-watchoutput2.csv: http://www1.abc.com/cms/slp/2/Flowerbomb http://www1.abc.com/cms/slp/2/Everlon-Jewelry... (5 Replies)
Discussion started by: ajayakunuri
5 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

Remove the values from a certain column without deleting the Column name in a .CSV file

(14 Replies)
Discussion started by: dhruuv369
14 Replies

5. UNIX for Dummies Questions & Answers

Creating a two column list of date pairs form a single column list

Hi all, looking for some help here. I'm what you'd call a dirty programmer. my shell scripts might be ugly, but they (usually) function... Say I have a single column text file with a list of dates (yyyymmdd) that represent the elevation of a point on that date (I work with land subsidence, so... (2 Replies)
Discussion started by: jbrandt1979
2 Replies

6. Shell Programming and Scripting

Pick the column value based on another column from .csv file

My scenario is that I need to pick value from third column based on fourth column value, if fourth column value is 1 then first value of third column.Third column (2|3|4|6|1) values are cancatenated. Main imp point, in my .csv file, third column is having price value with comma (1,20,300), it has... (2 Replies)
Discussion started by: Ganesh L
2 Replies

7. Shell Programming and Scripting

Need last column form file ..

Input File A A019 BXP_0_1 RRB12 (16,429) A019 BXP_1_1 RRB12 (17,431) A019 BXP_2_1 RRB12 (17,431) A021 BXP_0_1 RRB12 (16,316) A021 BXP_1_1 RRB12 (,315) A021 BXP_2_1 RRB12 A022 BXP_0_1 RRU12 (16,200) A022 BXP_1_1 RRU12 (17,198) A022 BXP_2_1 RRU12 (17,198) A024 BXP_0_1 RRU12 (16,283)... (9 Replies)
Discussion started by: asavaliya
9 Replies

8. Shell Programming and Scripting

exporting number into .csv file in text form (no other extra charc) from shell script

I have written a k shell program which is executing a sql and exporting data in numeric form like 0412323444 into .csv file. the problem i am facing is that , the data is coming in excel formatted in scientific form like 4.1+E08,while my requirement is to store data as such 0412323444 in excel ( no... (5 Replies)
Discussion started by: Deepak_Rastogi
5 Replies

9. Shell Programming and Scripting

deleting rows & columns form a csv file

Hi , I want to delete some rows & columns from file. can someone please help me on this? Regards. (2 Replies)
Discussion started by: code19
2 Replies
Login or Register to Ask a Question