CSV format problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CSV format problem
# 8  
Old 08-06-2007
I am getting this clear. what is your line 15 and 17, if possible please post the entire code so that we could help.
# 9  
Old 08-06-2007
#!/bin/bash

. ${HOME}/.std_dbrc
cd $STD_DBROOT
studentNo=$1
tmp=/tmp/acc2courses$ID.$$

grep -w "$studentNo" CSE1001 >/dev/null 2>&1
[ $? -eq 0 ] && tmpString=CSE1001
grep -w "$studentNo" CSE1002 >/dev/null 2>&1
[ $? -eq 0 ] && tmpString="$tmpString", CSE1002 ########Line 15
grep -w "$studentNo" CSE9001 >/dev/null 2>&1
[ $? -eq 0 ] && tmpString="$tmpString", CSE9001 ########Line 17
echo $tmpString


#IN TERMINAL
bash file_name cs012345
#This will return CSE2001 CSE2002 by my database file.
#This script will find student number in my database file to print course #number.
# 10  
Old 08-06-2007
Quote:
Originally Posted by ccwq
#!/bin/bash


[ $? -eq 0 ] && tmpString="$tmpString", CSE1002 ########Line 15
[ $? -eq 0 ] && tmpString="$tmpString", CSE9001 ########Line 17
I think the extra space after the tmpString is causing the error.

Code:
tomoo@Tomoo:~$ bash std_db_acc2courses cs123456
std_db_acc2courses: line 15: CSE1002: command not found
std_db_acc2courses: line 17: CSE9001: command not found

# 11  
Old 08-06-2007
Genius!
Thanks for helping
It works now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

LDAP data in CSV format

Hi all, I am new here, please don't eat me alive.. I am trying to find a good community to learn and participate in unix / linux discussions to help me improve in my current job. That being said, I have a problem which I didn't expect to challenge me, but I can't seem to find a viable... (8 Replies)
Discussion started by: tfm217
8 Replies

2. Shell Programming and Scripting

Format problem while converting text file to csv

Hi , I need a help in following scenario.I tried searching in google but couldn't able to find the exact answer. Sorry if i am re-posting already answered query. While i am trying to convert into log file into csv i couldn't able to get the format which i am looking for. I converted file... (4 Replies)
Discussion started by: varmas424
4 Replies

3. Shell Programming and Scripting

CSV data format manipulation

Hi There I need a script which will pick up the data from a .CSV file and reformat it as per the requirement and write it to another .CSV file. I am using an application that will only take data in a particular format and need something that will convert without manual intervention. The... (4 Replies)
Discussion started by: rbggbr16
4 Replies

4. Shell Programming and Scripting

Format csv file

Hi, I need to make some changes in a csv file using awk or perl. Unfortunately, all my attempts have led to nothing so I hope you guys can help me. I have the following example input file including header(original file has 35 fields): ABC: DE Time: 2012/09/07... (3 Replies)
Discussion started by: Subbeh
3 Replies

5. Shell Programming and Scripting

CSV format help

Hi team, In simple way i will explain.. i have a shell script which gives morethan one output echo"some code" ----> it gives one output echo"some code" ----> it gives one output echo"some code" ----> it gives one output echo"some code" ----> it gives one output i want all this to put... (0 Replies)
Discussion started by: darling
0 Replies

6. Shell Programming and Scripting

How to parse csv format?

Hi, I have a file with 3 fields in csv format: /tmp/foo/,MODIFY,bar/toto "/tmp/foo, bar/","ATTRIB,ISDIR","toto, tata/foobar"I would like to split fields in order to obtain the following: Line1: /tmp/foo/ MODIFY bar/totoLine2: /tmp/foo, bar/ ATTRIB,ISDIR toto, tata/foobarCan't find my way... (11 Replies)
Discussion started by: chebarbudo
11 Replies

7. Shell Programming and Scripting

Retaining the Unix CSV format in Excel format while exporting

Hi All, I have created a Unix Shell script whch creates a *.csv file and export it to Excel. The problem i am facing is that Users wants one of the AMOUNT field in comma separted values. Example : if the Amount has the value as 3000000 User wants to be in 3,000,000 format. This Amount format... (2 Replies)
Discussion started by: rawat_me01
2 Replies

8. Shell Programming and Scripting

format output in csv file

I am sending the output of a file to .csv file. The output should look like this: Total Customers Processed:,8 Total Customers Skipped:,0 Total Customers Added:,8 Total Customers Changed:,0 Total Policies Deleted:,0 Total Policies Failed:,0 total:,8 Now i want this output in... (1 Reply)
Discussion started by: Prashant Jain
1 Replies

9. Shell Programming and Scripting

Format CSV file

I have a csv file which I need to process and export back to xlsx file. For instance, the csv contains: John Smith, job-title, hours John Smith, job-title, hours Mary Smith job-title, hours etc. I need to import that to a script, get id of redundant data i.e: John smith, job-title,... (13 Replies)
Discussion started by: _tina_
13 Replies

10. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies
Login or Register to Ask a Question