extract .csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract .csv file
# 1  
Old 11-16-2009
extract .csv file

Hi all I am new to unix . I need to write a script that extracts some data from oracle into a .csv file with heading of the columns in the file

SO i created the following two scripts but they are not working

ac.sql (this is the sql file that i will call inside the shell script when i run these commands one after one and not in a script then it runs but it doesnt give me the name of the columns in the output file
)
set head off pages 0
set feedback off
SET NEWPAGE 0
SET SPACE 0
SET ECHO OFF
SET FEEDBACK OFF
SET TERM OFF
SET PAGESIZE 0
SET LINESIZE 32767
SET TRIMS ON
set verify off
set colsep ','
column c1 heading "Activitylogid" Format 99999999
column c2 heading "category" Format A50
column c3 heading "type" Format A50

spool sample.csv

select activity_log_id c1, activity_category c2,activity_type c3 from activitylog where rownum<100;

spool off

ab.sh ( this is the actual shell script when i run this it hangs )
#!/bin/sh

sqlplus -s user/pwd@ORCL@ac.sql
/
exit
eof

please suggest how to do it ... i have used .sql file because i want to suppress the sqlcommands in the output file
# 2  
Old 11-16-2009
Quote:
Originally Posted by rajesh_tns
...
ab.sh ( this is the actual shell script when i run this it hangs )
#!/bin/sh

sqlplus -s user/pwd@ORCL@ac.sql
/
exit
eof
...
Remove that "-s" and run your shell script and you'll know why it "hangs", or what exactly is going on.

Quote:
Originally Posted by rajesh_tns
... but it doesnt give me the name of the columns in the output file
...
It doesn't show the column headers because you either set heading off or pagesize 0 or both.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

.csv.gz file extract errors using Winzip

HI All, Currently, i am working on bash shell. I have generated the csv file via shell script and because of high size , i have zip the csv file and send it to the outlook in windows. filename : viswa.csv.gz i can able to receive the mail successfully , But i am not able to view the... (4 Replies)
Discussion started by: venkatviswa
4 Replies

2. Shell Programming and Scripting

How to extract start/end times from log file to CSV file?

Hi, I have a log file (log.txt) that which contains lines of date/time. I need to create a script to extract a CSV file (out.csv) that gets all the sequential times (with only 1 minute difference) together by stating the start time and end time of this period. Sample log file (log.txt) ... (7 Replies)
Discussion started by: Mr.Zizo
7 Replies

3. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies

4. Shell Programming and Scripting

Trying extract from text file and convert csv

I want to extract IP address, system ID and engine IDs of this file ( marked in red) and put in a csv. E.g. 1.1.1.1, SYSTEMID, 000012345678981123548912 I get these file by running an expect script from solaris. Here is the text file output of my expect script. working on 1.1.1.1 SNMP... (5 Replies)
Discussion started by: pbshillong
5 Replies

5. Shell Programming and Scripting

Extract data from XML file and write in CSV file

Hi friend i have input as following XML file <?xml version="1.0"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"> <BkToCstmrDbtCdtNtfctn> <GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>... (3 Replies)
Discussion started by: mohan sharma
3 Replies

6. Shell Programming and Scripting

Extract last cell of csv file

How do I extract the last cell in a column of a csv file using linux shell scripting? Or alternatively, how do I get the number of cells of a csv file? (2 Replies)
Discussion started by: locoroco
2 Replies

7. UNIX for Dummies Questions & Answers

How to extract one column from csv file in perl?

Hi everyone, i am new to perl programming, i have a problem in extracting single column from csv file. the column is the 20th column, please help me.. at present i use this code #!C:/perl/bin use warnings; use strict; my $file1 = $ARGV; open FILE1, "<$file1" or die "Can't... (13 Replies)
Discussion started by: kvth
13 Replies

8. Shell Programming and Scripting

How to extract data from csv file

Hello everybody, Here is my problem, I don't know anything about shell programming and my boss is actually asking me to develop a shell script in order to get values in a csv file from a specific date. Here is a sample of the csv file : Date;Enchaînement;Titre;Libellé ;calendrier;Heure début;Heure... (11 Replies)
Discussion started by: freyr
11 Replies

9. Shell Programming and Scripting

extract pattern from csv file

hi, i have a situation where i have a csv file in the format date,name eg: 1284631889869,a 1284631889879,b 1284631889459,c . . . . . . . now i take a time and an interval from user. (5 Replies)
Discussion started by: niteesh_!7
5 Replies

10. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies
Login or Register to Ask a Question