Visit Our UNIX and Linux User Community


reading data from excel using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading data from excel using shell script
# 8  
Old 01-05-2008
Hi porter
Should I be storing the data from csv file in a variable?

I use sybase

Thanks
# 9  
Old 01-06-2008
Quote:
Originally Posted by tiger99
Should I be storing the data from csv file in a variable?
I thought you would be reading the data from the separate columns then generating the "insert" SQL statements.
# 10  
Old 01-06-2008
IMHO, If your goal is to select the first column out of your csv/xls file, and then use it in a stored procedure, I would suggest that you use awk to extract out the first column into a flat file, load that file into a temp table and then reference the temp table from your stored procedure.

Not sure how many rows you will have in thie csv/xls file, but the more rows you will have, the tricky it will be to pass it into the stored procedure. Look for a more robust solution.
# 11  
Old 01-06-2008
Hi porter

sorry, I would not be doing any "insert" SQL statement.

I need to
1. use shell script to read the first column of data in csv file
2. pass the data to a sybase stored procedure using shell script
3. in the stored procedure, I would have a "select" SQL statement (i.e select * from db where id in (1234,2345,....))

1234,2345... are data from the first column of the csv file.

I hope I make my question clear

Thanks
# 12  
Old 01-06-2008
this is one way how you get your first column data
Code:
# cut -f1 -d"," < csvfile | paste -sd","
1234,2345,3345

you just have to assign the select statement to a variable using the above method
Code:
cmd="select * from table where id in ( `the above command` )"
isql -uUser -Sserver <options> << EOF
 exec procedure $cmd
EOF

Since you are beginner to shell, you can read up some tutorial first. see here for some tutorials

Previous Thread | Next Thread
Test Your Knowledge in Computers #522
Difficulty: Medium
11,223 = 0x2BD7
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading a column from excel using shell script in Linux environment

Hi all I am new to shell scripting. I need to read the 1st column and last of the excel file in linux environment. Can some one help me with examples (3 Replies)
Discussion started by: Vigneshj28
3 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

How to write text file data to excel using UNIX shell script?

Hi All, I have the requirement in unix shell script. I want to write the "ls -ltr" command out put to excel file as below. Input :text file data : drwxr-xr-x 5 root root 4096 Oct 2 12:26 drwxr-xr-x 2 apx aim 4096 Nov 29 18:40 drwxr-xr-x 5 root root 4096 Oct 2 12:26 drwxr-xr-x... (10 Replies)
Discussion started by: Balasankar
10 Replies

4. Shell Programming and Scripting

Need help on inserting data from text file to excel using shell script

Hi, Please help me on this. I want to insert data from text file to excel using shell script nawk -v r=4 -v c=4 -v val=$a -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' "file.csv" I used above one to insert $a value in 4th row, 4th column in an excel file.csv and it... (3 Replies)
Discussion started by: suman.frnz
3 Replies

5. Shell Programming and Scripting

Export data from database in Excel sheet with the help of Shell script and automated the report

Export data from database in Excel sheet with the help of Shell script and automated the report every day in the mornig. (1 Reply)
Discussion started by: neeraj617
1 Replies

6. Shell Programming and Scripting

Reading the data from CSV and performing search through shell script

Hello, I am working on building a script that does the below actions together in my Linux server. 1) First, have to read the list of strings mentioned in CSV and store it in the shell script 2) Second, pick one by one from the string list, and search a particular folder for files that... (2 Replies)
Discussion started by: vikrams
2 Replies

7. UNIX for Advanced & Expert Users

put data in excel file using shell script

Hi. I wish to add data in a specific excel file on daily basis.However the currect dat's data should always come on top i.e for example should always occupy cell A7,B7,C7 .. and the data of day before which was earlier on 7th row of each coloumn should move to 8th row..data on 8th row should... (1 Reply)
Discussion started by: kanus
1 Replies

8. Shell Programming and Scripting

how to put data using shell script to a excel file

Hi, Can any one tell me how to put data using shell script to a excel file from text file to other columns of excel file,leaving first column unaffected i.e it should not overwrite data in first column. Say my text file data is: 15-dec-2008 15-dec-2009 16-dec-2008 16-dec-2009 say my first... (1 Reply)
Discussion started by: siri_886
1 Replies

9. Shell Programming and Scripting

Filter data in Excel sheet using Shell Script

Hi, I have an excel sheet which has 100000 records. All these records are having 3 columns each with the last column as "Y" or "N". I would like to filter those records which has the value "Y". Can you please let me know how to proceed with that? Thanks in advance. -Sri ----------... (8 Replies)
Discussion started by: bhanusri83
8 Replies

10. Shell Programming and Scripting

Reading data from a file through shell script

There is one Text file data.txt. Data within this file looks like: a.sql b.sql c.sql d.sql ..... ..... want to write a shell script which will access these values within a loop, access one value at a time and store into a variable. can anyone plz help me. (2 Replies)
Discussion started by: Dip
2 Replies

Featured Tech Videos