How to spool CSV file

Hi,
I want to spool a csv file from unix.. I have a shell script where im calling the .sql file in returns it select the data from the table and spool it to CSV..
THe problem i have here when i spool it , it is not comming in the right format..
for ex :
set head on;
set feed off;
set trimspool on;
set linesize 32627;
set pagesize 32627;
set echo off;
set termout on;
O/p is like
empid ename sal mgr
1234 xysss 2323232 wewew
Can anyone please help me out...

Hi,
When posting formatted text (such as your output) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
What's wrong with the current output?
What is the correct output you want?
A lot of folks concatenate all their output into one big string column for CSV output.
That is, instead of:SELECT     empid
,     ename
,     hiredate
,     sal
they say:SELECT     empid
|| ',' || ename
|| ',' || TO_CHAR (hiredate, 'DD-MON-YYYY')
|| ',' || sal
Most of the time, NUMBER columns don't require special formatting, but DATEs often do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to upload .CSV file from Application Server

    Hi Experts,
        How to upload .CSV file separated by ',' from Application server to an internal table.
    Invoice No,Cust No,Item Type,Invoice Date,days,Discount Amount,Gross Amount,Sales Amount,Customer Order No.,Group,Pay Terms
    546162,3233,1,9/4/2007,11,26.79,5358.75,5358.75,11264,HRS,11
    546163,2645,1,9/4/2007,11,3.07,305.25,305.25,10781,C,11
    Actually I read some already answered posts. But still I have some doubts.
    Can anybody please send me the code.
    Thanks in Advance.

    Hi Priya,
    Check this code
    Yhe logic used here is as follows,
    Get all the data into an internal table in the simple format ie: a row with one field contains an entire line
    After getting the data, we split each line of the table on every occurrence of the delimiter (comma in your case)
    Here, I have named the fields as field01, field02 etc, you could use your own names according to your requirement
    parameters: p_file(512).
      DATA : BEGIN OF ITAB OCCURS 0,
              COL1(1024) TYPE C,
             END OF ITAB,
             WA_ITAB LIKE LINE OF ITAB.
      DATA: BEGIN OF ITAB_2 OCCURS 0,
        FIELD01(256),
        FIELD02(256),
        FIELD03(256),
        FIELD04(256),
        FIELD05(256),
        FIELD06(256),
        FIELD07(256),
        FIELD08(256),
        FIELD09(256),
        FIELD10(256),
        FIELD11(256),
        FIELD12(256),
        FIELD13(256),
        FIELD14(256),
        FIELD15(256),
        FIELD16(256),
       END OF ITAB_2.
      DATA: WA_2 LIKE LINE OF ITAB_2.
        OPEN DATASET p_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
        IF SY-SUBRC = 8.
          WRITE:/ 'File' , p_FILE , 'cannot be opened'.
          LV_LEAVEPGM = 'X'.
          EXIT.
        ENDIF.
        WHILE SY-SUBRC <> 4.
          READ DATASET p_FILE INTO WA_ITAB.
          APPEND WA_ITAB TO ITAB.
        ENDWHILE.
        CLOSE DATASET p_FILE.
      LOOP AT ITAB INTO WA_ITAB.
        SPLIT WA_ITAB-COL1 AT ','    " where comma is ur demiliter
         INTO WA_2-FIELD01 WA_2-FIELD02 WA_2-FIELD03 WA_2-FIELD04
         WA_2-FIELD05 WA_2-FIELD06 WA_2-FIELD07 WA_2-FIELD08 WA_2-FIELD09
         WA_2-FIELD10 WA_2-FIELD11 WA_2-FIELD12 WA_2-FIELD13 WA_2-FIELD14
         WA_2-FIELD15 WA_2-FIELD16.
        APPEND WA_2 TO ITAB_2.
        CLEAR WA_2.
      ENDLOOP.
    Message was edited by:
            Kris Donald

  • How to save CSV file in application server while making infospoke

    How to save CSV file in application server to be used as destination while making infospoke.
    Please give the steps.........

    Hi
    If you want to load your flatfile from Application server,then you need to trasfer your file from your desktop(Computer) to Application server by using FTP.
    Try using ARCHIVFILE_CLIENT_TO_SERVER Function module.
    You Just need to give thesource path and the target path
    goto SE37 t-code , which is Function module screen, give the function name ARCHIVFILE_CLIENT_TO_SERVER, on click F8 Execute button.
    for path variable give the file path where it resides like C:\users\xxx\desktop\test.csv
    for target path give the directory path on Application server: /data/bi_data
    remember the directory in Server starts with /.
    U have to where to place the file.
    Otherwise use 3rd party tools to connect to ur appl server like : Core FTP and Absolute FTP in google.
    Otherwise...
    Goto the T.code AL11. From there, you can find the directories available in the Application Server.
    For example, if you wanna save the file in the directory "DIR_HOME", then you can find the path of the directories in the nearby column. With the help of this, you can specify the target path. Specify the target path with directory name followed by the filename with .CSV extension.
    Hope this helps
    regards
    gaurav

  • How to send CSV files to external server

    Hi All,
    How to send CSV files to external server (not to application server).
    I know how to download files to application server.
    Please give me the steps to send CSV files to external server.
    Is it posiible with RFCs? If yes, then plz provide me the steps. Do we need to create RFC destination for this.
    Appriciate your help with rewarding points.
    Please help as this is an urgent requirement

    hi,
    you can send via xi.
    chk this blog
    a) content conversion (sender)
    /people/sap.user72/blog/2005/01/06/how-to-process-csv-data-with-xi-file-adapter
    b)content conversion (receiver)
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    <b>
    reward points if this helps you.</b>
    Siva
    Message was edited by:
            SivaKumar

  • How to send .CSV file via email in Oracle10g/11g PL/SQL

    Hi Guys,
    Can any one let me know or suggest me how to send .csv file via email attachment using Oracle PL/SQL.
    Thanks in advance!
    Regards,
    LRK

    A FAQ. Use UTL_MAIL (if attachment is 32KB less). Else use UTL_SMTP. Search this forum. Search using google.

  • How to upload CSV file w/o ,, for the last line

    Hi Experts,
    As part of one interface uploading the csv file (4coulmns) manually using the TCODE: CSCA_FILE_COPY.
    After uploading when i see in the AL11 as it is csv file it is filling the , in each space.
    But my issue while running the interface (because of logic in it) checking for the hash total in the last line where (record count, hash total) only 2 items should come but because of manual upload adding the (record count, hash total, , ,) another two spaces.
    Where program not moving further becasue the it is alway comparing the amounts (1000.00 not matching with 1000.00, , ) it is not processing. In production files directly load in to unix server so no issues and i can't ask to change the program code...because iam not following the process. As part of testing i've to do manually only.
    Please suggest the workaround for this.
    Is it possible to change the contents directly in AL11 directly....then HOW ?
    or
    How to create a csv file w/o , , in the last line (may be it is not possible) ?
    Thanks for your replies in advance.
    Regards
    VVR

    I don't think you can edit from AL11, nor creating a CSV without those commas at the end because are created to state fields with empty value.
    You have 6 columns filled with values but for the last line you only fill the first four. It is expected to appear , , for the last 2 columns on the last line.
    I can only suggest keep doing it manually before uploading the CSV file... or... you are saying you can't change the program.
    How about upload all CSV files... then writing another program to get those files from AL11 and delete the spare commas at the end line?
    Cheers,
    Andres.

  • How to load csv file in oracle table

    Hi,
    i have csv files to which i want to load the csv file data and table structure in oracle. my csv files on the window machine but database is runing on ibm aix.so how to do it please any one can help me about. thanks a lot in advance
    i know th syntax below
    $sqlldr userid=username/password control=<filename> log=<log filename>

    Hello,
    Yes, with SQL*Loader you can do it.
    But first you have to create a Table into your database with columns and datatype matching
    the content of you "csv" file.
    Then, you'll have to prepare a control file and use the option fields terminated by "," as it's
    a "csv" format.
    Then, you could execute your statement.
    Please, find enclosed a link with some example about SQL*Loader and "csv" file:
    [http://www.orafaq.com/wiki/SQL*Loader_FAQ]
    Hope this help.
    Best regards,
    Jean-Valentin

  • How to use csv files in OWB

    Hi Experts
    I have one UNIX server and i my user is putting the csv files on windows machine. I want
    1. If User put some new csv file in windows machine it should automatically reflect in UNIX machine.
    2. If user enter some data in windows csv files then it should be reflect in UNIX csv files automatically
    3. Now I want to connect my OWB with these UNIX csv fils. my csv files are in /home/oracle.source directory.
    Regards
    Frnd

    Let me give an insight of how it works for me:
    1. A CSV file is created in unix at a specified location.
    2. Using ULTRAEDIT software(installed on windows client) FTP is configured to access the unix server.
    3. Open the file stored in unix through ULTRAEDIT from windows.
    4. MAKE changes to the file from ultraedit in windows.
    5. SAVE it and close ULTRAEDIT.
    The changes will be automatically reflected in unix without having the need to FTP it.
    OWB accesses the CSV file from unix and does further processing.
    Not sure if OPs can do this but this is probably the easiest way of achieving what he wants and this approach works very well for me.

  • How to create csv file in stored procedure

    I want the output of my stored procedure in a csv file. How can I do that?

    1) define File Paths
    2) Write the output comma seperated to the file.
    Simple :)
    Hope you are comfortable with File operations.
    URL for your reference
    PL/SQL output to .CSV file
    Regards,
    Bhushan

  • How to open .csv files?

    How can I open .csv files that are sent as attachments.  I get reports sent automatically from an app that only saves them as a .csv and I cannot find a way to open them on my BB.  I've looked at a few add on software options but none of the ones I've found open .csv files.
    Any ideas? 
    Thanks 
    8703e v4.1 and Blackberry Professional Software on the server

    Sorry, but .csv files are not currently a supported format.
    Supported attachment formats for BlackBerry mail and messaging

  • How to convert csv files into java bean objects?

    Hi,
    I have a CSV file, I want to store the data availabale in that csv file into java bean, I am new to this csv files how can I convert CSV files into java beans.
    Please help me.
    Adavanced Thanks,
    Mahendra

    You can use the java.io API to read (and write) files. Use BufferedReader to read the CSV file line by line. Use String#split() to split each line into an array of parts which were separated by comma (or semicolon). If necessary run some escaping of quotes. Finally collect all parts in a two-dimensional List of Strings or a List of Javabeans.
    java.io API: [http://www.google.com/search?q=java.io+javase+api+site:sun.com]
    java.io tutorial: [http://www.google.com/search?q=java.io+tutorial+site:sun.com]
    Basic CSV parser/formatter example: [http://balusc.blogspot.com/2006/06/parse-csv-upload.html]

  • How to spool a file in sqlplus with feedback off option?

    Is there a way to spool a file in sqlplus with the feedback turn off? I want to capture all the logs, but do not want to see all commands and entries on my screen. When I set the feedback off, I get nothing in my logfiles due to the set feedback off option.

    here's what i did
    SET echo off
    SET feedback off
    SET term off
    SET pagesize 0
    SET linesize 200
    SET newpage 0
    SET space 0
    col name format a120
    SQL> spool test.log
    SQL> @trunc_ref_tables.sql -- this script truncates tables
    SQL> spool off
    SQL> exit
    As expected, there was no logs generated in the logfile with the set feedback off option. This is what was in my log file.
    SQL> @trunc_ref_tables.sql
    SQL> spool off
    How do i see the list of tables that were truncated in my logfiles without havign to see the following on my screen.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.
    Table truncated.

  • How To Read CSV file?

    Hi,
    I have to Read a CSV(Comma Separated Value) File in java. But i don't know how to pass the CSV file name during Runtime. I tried this but not working:::::::
    c:\jdk1.3\bin java Rfile csv.dat // {Rfile is my java source code file}
    kindly help

    hi My Far Away Friend,
    At First Thx for the help . But the suggestion U have given to me is already tried by me. I am sending my java Code to you along with the errors so that I can expect a better help from you. I hope U will help me out.
    My Java Code:::::::::
    import java.io.*;     // For input from File
    import java.sql.*;     // For database operations
    import java.util.*;     // for Tokenizing coma separated values
    public class Rfile
         public static void main(String ar[]) throws Exception
              if(ar.length <1)
                   System.out.println("usage : java Rfile <csv2.csv> ");
                   System.exit(0);
              FileInputStream fis;          // to read file
              DataInputStream dis;          // to fetch file data
              Connection con;               // Database connection
              Statement st;               // Statement object for inserting records
              StringTokenizer stoken;          //
                        fis = new FileInputStream(ar[0]);
              dis = new DataInputStream(fis);
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con = DriverManager.getConnection("jdbc:odbc:surajtest");
              String data = "";
              int totcount = 0;
              while((data = dis.readLine())!= null)
                   stoken = new StringTokenizer(data,",");
                   String MyTime = stoken.nextToken();
                   String GridFreq = stoken.nextToken();
                   String NtpcGen = stoken.nextToken();
                   String NlciiGen = stoken.nextToken();
                   String MapsGen = stoken.nextToken();
                   String KapsGen = stoken.nextToken();
                   String APGen = stoken.nextToken();
                   String KarGen = stoken.nextToken();
                   String KerGen = stoken.nextToken();
                   String TNGen = stoken.nextToken();
                   String APDem = stoken.nextToken();
                   String KarDem = stoken.nextToken();
                   String KerDem = stoken.nextToken();
                   String TNDem = stoken.nextToken();
                   String PondyDem = stoken.nextToken();
                   String GovaDem = stoken.nextToken();
                   String APDwl = stoken.nextToken();
                   String KerDwl = stoken.nextToken();
                   String TNDwl = stoken.nextToken();
                   String PdyDwl = stoken.nextToken();
                   String GoaDwl = stoken.nextToken();
                   String APSch = stoken.nextToken();
                   String KarSch= stoken.nextToken();
                   String KerSch = stoken.nextToken();
                   String TNSch = stoken.nextToken();
                   String PdySch = stoken.nextToken();
                   String GovaSch = stoken.nextToken();
                   String EastGzkExc = stoken.nextToken();
                   String EastUsilExc = stoken.nextToken();
                   String WestRdmExc = stoken.nextToken();
                   String WestAmdExc = stoken.nextToken();
                   st = con.createStatement();
    String strStmt = "insert into projtab1 values('"+MyTime+"','"+GridFreq+"'," NtpcGen ",'" + NlciiGen + "','" MapsGen "','" + KapsGen +"','"+APGen+"','"+KarGen+"','"+KerGen+"','"+TNGen+"','"+APDem+"','"+KarDem+"','"+KerDem+"','"+TNDem+"','"+PondyDem+"','"+GovaDem+"','"+APDwl+"','"+KerDwl+"','"+TNDwl+"','"+PdyDwl+"','"+GoaDwl+"','"+APSch+"','"+KarSch+"','"+KerSch+"','"+TNSch+"','"+PdySch+"','"+GovaSch+"','"+EastGzkExc+"','"+EastUsilExc+"','"+WestRdmExc+"','"+WestAmdExc + "')";
                   //System.out.println("Insert St: " + strStmt);
                   int rcount = st.executeUpdate(strStmt);
                   totcount += rcount;
                   st.close();
                   st = null;
                   stoken = null;
                   System.out.println(totcount + ", record(s) inserted into the database");
                   con.close();
                   con = null;
                   dis.close();
                   dis = null;
                   fis.close();
                   fis = null;
    /* Error I got:::::
    D:\Backup\jdk1.3\bin>java Rfile d:\csv.dat(GIVING THE WHOLE PATH BUT STILL ERROR)
    d:\csv2.xls
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
    at Rfile.main(Rfile.java:28)
    =========================================================================
    D:\Backup\jdk1.3\bin>java Rfile csv.dat (GIVING ONLY FILE NAME BUT STILL ERROR)
    Exception in thread "main" java.io.FileNotFoundException: csv2.xls (The system
    cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:64)
    at Rfile.main(Rfile.java:24)
    ==========================================================================
    (NORMAL COMPILATION)
    D:\Backup\jdk1.3\bin>javac Rfile.java
    Note: Rfile.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    ==========================================================================
    (COMPILING WITH DEPRACATION)
    D:\Backup\jdk1.3\bin>javac -deprecation Rfile.java
    Rfile.java:35: warning: readLine() in java.io.DataInputStream has been deprecated
    while((data = dis.readLine())!= null)
    ^
    1 warning (AFTER COMPILING I GOT THIS WARNING)
    waiting for a quick reply from you i remain...............
    An awaited Friend..........
    Debasis

  • Anyone know how to upload csv file to temp table of sybase DB from java?

    Dear All,
    I blindly need your help in achieving the following:
    I have the csv file which contains OrdId and BillId values. I just wanted to read these two values one by one from excel and loaded them into one temp table of Sybase SQL Anywhere.
    here is the sample query for your reference:
    begin tran
    create table tempdb..ordBill (ord_id int identity,bill_id int
    go
    load table tempdb..ordBill from 'c:\\test\\test.csv'Error:
    Incorrect syntax near the keyword 'table'.
    I am having only one tool Microsoft ISQL/W from which i connect to remote sybase DB and run some queries like sp_help , create etc.. from there.
    It would be great,if somebody knows the way of doing the above thru some java program. Otherwise, is there any tool like BCP required to do the above?
    Awaiting for your valuable reply
    thanks
    pannar

    Hi,
    I could connect to my Sybase DB thru java program. Can somebody help me how to upload the csv file into sybase temp table ?
    Here is the sample code:
    import java.sql.*;
    public class DBConn {
    public DBConn(){
    public static void main(String[] args) {
    try {
    //Class.forName("com.sybase.jdbc2.jdbc.SybDriver.class.getname()");
    //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
    String sourceURL = "jdbc:sybase:Tds:ldbd1.devo.ilx.com:5000";
    Connection conn = DriverManager.getConnection(sourceURL, "pannar", "pannar");
    //Connection conn = DriverManager.getConnection(sourceURL);
    System.out.println("Success");
    } catch (Exception e) {
    System.err.println("Got an excpetion! ");
    e.printStackTrace();
    }

  • How to send csv file as an attachment

    Hi,
    I am able to create a csv file in this directory as "test.scv" using utl_file and some select statements.
    Now I need to send this csv file as an attachment in email.
    we have smtp installed on our server.
    Please help me on this .
    Thanks
    Kind Regards

    The first link takes in a filename (this would be the csv file you have already created) so nothing should be hard coded; it's just the parameters you pass in.
    Doing a little more research (from the asktom article I posted previously) links to this [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html] which the real gold is at [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt]:
    with examples how to use it at [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/mailexample_sql.txt].
    To get the attachments working from a PL/sql application you will require one of the packages or a large amount of code.
    here's the coded example for attaching files from the packages listed in maildemo_sql.txt from Oracle's website
    REM Send an email with 2 attachments.
    DECLARE
      conn      utl_smtp.connection;
      req       utl_http.req; 
      resp      utl_http.resp;
      data      RAW(200);
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => 'Me <[email protected]>',
        recipients => 'Someone <[email protected]>',
        subject    => 'Attachment Test',
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.attach_text(
        conn      => conn,
        data      => '<h1>Hi! This is a test.</h1>',
        mime_type => 'text/html');
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'image/gif',
        inline       => TRUE,
        filename     => 'image.gif',
        transfer_enc => 'base64');
      -- In writing Base-64 encoded text following the MIME format below,
      -- the MIME format requires that a long piece of data must be splitted
      -- into multiple lines and each line of encoded data cannot exceed
      -- 80 characters, including the new-line characters. Also, when
      -- splitting the original data into pieces, the length of each chunk
      -- of data before encoding must be a multiple of 3, except for the
      -- last chunk. The constant demo_mail.MAX_BASE64_LINE_WIDTH
      -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
      -- of data before encoding.
      req := utl_http.begin_request('http://www.some-company.com/image.gif');
      resp := utl_http.get_response(req);
      BEGIN
        LOOP
          utl_http.read_raw(resp, data, demo_mail.MAX_BASE64_LINE_WIDTH);
          demo_mail.write_raw(
            conn    => conn,
            message => utl_encode.base64_encode(data));
        END LOOP;
      EXCEPTION
        WHEN utl_http.end_of_body THEN
          utl_http.end_response(resp);
      END;
      demo_mail.end_attachment( conn => conn );
      demo_mail.attach_text(
        conn      => conn,
        data      => '<h1>This is a HTML report.</h1>',
        mime_type => 'text/html',
        inline    => FALSE,
        filename  => 'report.htm',
        last      => TRUE);
      demo_mail.end_mail( conn => conn );
    END;
    /Edited by: tanging on Dec 18, 2009 10:58 AM

Maybe you are looking for

  • IPod Classic 120GB won't sync songs

    My iPod recently began having issues, such as not playing songs that should've worked, skipping over them, etc. So I chose to restore it, and now it stops syncing songs at around 3 GB worth of music, and I'll either get error 1303, 53, or 69. I sync

  • TS3682 back up in different folder

    i used to back up ipad in i cloud and then change preference to backup in computer. which location does the back up goes.? if i want to backup in a location of my own how to i go about

  • Problem with generating WSDL from ABAP

    Hi all I have encountered a problem.I created a WSDL from a ABAP program,but in the ABAP function module what it does is it inserts value onto a transparent table from a table which let me specify as a virtual table.So after generating the wsdl i am

  • Just updated to 7.1 and now library music skips

    I just downloaded version 7.1 and now the first 3-10sec of random songs skip like my computer is having a seizure when playing crossfade playback. Is anyone else having this issue? Never had any problems until this update. Already deleted my library

  • Start up with white page and a folder with ? plz help

    i just bought a macbook pro and the first time it started good, but the second time it stuck on the white page and have a folder with the ? on it, can anyone help me....??