Sponsored Content
Top Forums Shell Programming and Scripting Read CSV column value based on column name Post 302373264 by JohnGG on Friday 20th of November 2009 12:33:30 AM
Old 11-20-2009
Thank Tony ,

I have tried the following code giving error , please do the needful
John.csv is the file name

If i give the column name as Password and row number as 4 the result I should get '

'Scot3'



Code:
cat John.csv if [ $1 = "Username" ]
then
  Column=1
elif  [ $1 = "Password" ]
then
  Column=2
fi
echo $Column
read line
Wanted=$1
set $line
if [ $Wanted = $1 ]
then
  Column=1
else 
  echo "Hello"
fi


Thanks and Regards,
John

Last edited by Franklin52; 11-20-2009 at 06:23 AM.. Reason: Please indent your code and use code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sorting csv file based on column selected

Hi all, in my csv file it'll look like this, and of course it may have more columns US to UK;abc-hq-jcl;multimedia UK to CN;def-ny-jkl;standard DE to DM;abc-ab-klm;critical FD to YM;la-yr-tym;standard HY to MC;la-yr-ytm;multimedia GT to KJ;def-ny-jrt;critical I would like to group... (4 Replies)
Discussion started by: tententen
4 Replies

2. Shell Programming and Scripting

extract csv based on column value

Hi I have a csv file which is below A,5 B,6 C,10 D,7 I want the values who's second column is greater than 7 say C,10 D,7 Help me please... Thanks, Maruth (3 Replies)
Discussion started by: maruthavanan
3 Replies

3. Shell Programming and Scripting

awk read column csv and search in other csv

hi, someone to know how can i read a specific column of csv file and search the value in other csv columns if exist the value in the second csv copy entire row with all field in a new csv file. i suppose that its possible using awk but i m not expertise thanks in advance (8 Replies)
Discussion started by: giankan
8 Replies

4. Shell Programming and Scripting

Read in 2-column CSV, output many files based on field

Is there a way to read in a two-columned CSV file, and based on the fields in 1st column, output many different files? The input/output looks something like: input.csv: call Call Mom. call Call T-Mobile. go Go home. go Go to school. go Go to gas station. play Play music. play Play... (4 Replies)
Discussion started by: pxalpine
4 Replies

5. 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

6. Linux

Filter a .CSV file based on the 5th column values

I have a .CSV file with the below format: "column 1","column 2","column 3","column 4","column 5","column 6","column 7","column 8","column 9","column 10 "12310","42324564756","a simple string with a , comma","string with or, without commas","string 1","USD","12","70%","08/01/2013",""... (2 Replies)
Discussion started by: dhruuv369
2 Replies

7. Shell Programming and Scripting

Fetching values in CSV file based on column name

input.csv: Field1,Field2,Field3,Field4,Field4 abc ,123 ,xyz ,000 ,pqr mno ,123 ,dfr ,111 ,bbb output: Field2,Field4 123 ,000 123 ,111 how to fetch the values of Field4 where Field2='123' I don't want to fetch the values based on column position. Instead want to... (10 Replies)
Discussion started by: bharathbangalor
10 Replies

8. Shell Programming and Scripting

Compare two csv's with column based

Hi, I am having below two CSV's col_1,col_2,col_3 1,2,4 1,3,6 col_1,col_3,col2,col_5,col_6 1,2,3,4,5 1,6,3,,, I need to compare based on the columns where the mismatch is expected output col_1,col_2,col_3 1,2,4 (3 Replies)
Discussion started by: rohit_shinez
3 Replies

9. 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

10. UNIX for Beginners Questions & Answers

Filtering records of a csv file based on a value of a column

Hi, I tried filtering the records in a csv file using "awk" command listed below. awk -F"~" '$4 ~ /Active/{print }' inputfile > outputfile The output always has all the entries. The same command worked for different users from one of the forum links. content of file I was... (3 Replies)
Discussion started by: sunilmudikonda
3 Replies
quot_vxfs(1M)															     quot_vxfs(1M)

NAME
quot_vxfs: quot - summarize ownership on a VxFS file system SYNOPSIS
filesystem ... DESCRIPTION
displays the number of 1024-byte blocks in the specified VxFS filesystem that are currently owned by each user. filesystem is either the name of the directory on which the file system is mounted or the name of the device containing the file system. Options recognizes the following options: Specifies file system type. Generate a report for all mounted file systems. Report file system size instead of user statistics. The option generates histogram statistics in 3-column format: Column 1: File size in blocks. Sizes are listed in ascending order up to 499 blocks per file. Files occupying 499 or more blocks are counted together on a single line as 499-block files, but column 3 is based on actual number of blocks occupied. Column 2: Number of files of size indicated in column 1. Column 3: Cumulative total blocks occupied by files counted in current plus all preceding lines. The option overrides the and options. Display the number of files and space occupied by each user. Calculate the number of blocks in the file based on file size rather than actual blocks allocated. The option does not account for sparse files (files with holes in them). Accept ncheck(1M) data as input. The following pipeline will produce a list of all files and their owners: Display three columns containing the number of blocks not accessed in the last 30, 60, and 90 days. Validate the command line options, but do not execute the command. If the options specified are valid, echoes the complete command line. If the options specified are not valid, it prints an error message. Operands recognizes the following operand: filesystem Name of the directory on which the VxFS file system is mounted or the name of the device containing the file system.. EXAMPLES
The following examples show the output of using various options. AUTHOR
Disk Quotas were developed by the University of California, Berkeley, Sun Microsystems, Inc., and HP. FILES
Mounted file system table Password file (contains user names). SEE ALSO
du(1), find(1), ls(1), fstyp(1M), mount(1M), ncheck(1M), quot(1M), repquota(1M), quota(5). quot_vxfs(1M)
All times are GMT -4. The time now is 12:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy