Creating CSV file

Hi,
How can i convert the out of a SQL query to CSV file format on solaris without using spool.
Any help will be great.
zubair.

set lin 9999 trimsp on pages 0 ver off feedb off long 99999999
PROMPT EMPNO;ENAME;DEPTNO
select empno||';'||ENAME||';'||DEPTNO from emp;
EMPNO;ENAME;DEPTNO
7369;SMITH;20
7499;ALLEN;30
7521;WARD;30
7566;JONES;20
7654;MARTIN;30
7698;BLAKE;30
7782;CLARK;10
7788;SCOTT;20
7839;KING;10
7844;TURNER;30
7876;ADAMS;20
7900;JAMES;30
7902;FORD;20
7934;MILLER;10

Similar Messages

  • Problem in creating csv file

    I have one problem in creating csv file.
    If one column has single line value, it is coming in single cell. But if the column has no.of lines using carriage return while entering into the table,
    I am not able to create csv file properly. That one column value takes more than one cell in csv.
    For example the column "Issue" has following value:
    "Dear
    I hereby updated the Human Resources: New User Registration Form Request.
    And sending the request for your action.
    Regards
    Karthik".
    If i try to create the csv file that particular record is coming as follows:
    0608001,AEGIS USERID,SINGAPORE,Dear
    I hereby updated the Human Resources: New User Registration Form Request.
    And sending the request for your action.
    Regards
    Karthik,closed.
    If we try to load the data in table it is giving error since that one record is coming in more than one line. How can I store that value in a single line in csv file.
    Pls help.

    I have tried using chr(10) and chr(13) like this......still it is not solved.
    select REQNO ,
    '"'||replace(SUBJECT,chr(13),' ')||'"' subject,
    AREA ,
    REQUESTOR ,
    DEPT ,
    COUNTRY ,
    ASSIGN_TO ,
    to_Date(START_DT) ,
    START_TIME ,
    PRIORITY ,
    '"'||replace(issues, chr(13), ' ')||'"' issues,
    '"'||replace(SOLUTIONS,chr(13),' ')||'"' SOLUTIONS ,
    '"'||replace(REMARKS,chr(13),' ')||'"' REMARKS ,
    to_date(CLOSED_DT) ,
    CLOSED_TIME ,
    MAN_DAYS ,
    MAN_HRS ,
    CLOSED_BY ,
    STATUS from asg_log_mstr
    Pls help.

  • Can we create .CSV files through documaker

    Hi,
    Is it possible to create .csv files through documaker apart from pdf's
    Thanks

    With apologies, it is still unclear (to me) what you are asking.
    It is possible to create files using DAL, but to offer more specific guidance requires a better understanding of what it is that you want.
    A CSV is a Comma-Separate Value file. A PDF file is a printed document file containing formatted text content, graphics, lines, boxes, etc - in other words a fully-composed document.  I'm not exactly sure how a PDF and a CSV file could contain the same data.
    Are you perhaps asking to get an index of the created PDF files written as a CSV file? Something that contains a row of key transaction data along with the file name of the generated PDF? Perhaps something akin to the batch (BCH) files that can be produced per transaction recipient?
    Are you asking for an export file of all the field data that went into the creation of the document and included in the PDF? Normally a CSV has a header that describes the columns and then each row of data would be consistent with that header. Without knowing that every PDF file you create will have exactly the same number of fields defined, it is difficult to imagine that a single CSV file would be sufficient. And depending upon the number of fields and the size of the data assigned to each, this could be quite a long record per PDF in the resulting CSV file.
    Or perhaps you had in mind to get a name / value pair written for each field with data written on separate lines? This would not a be a true CSV file, but could have the name and values separated by commas if that is what you require.
    You have something specific in mind and yet, we are not in your mind.  We need more specific information on exactly what you are trying to accomplish.

  • How to create .csv file from ABAP report

    Hi
    We have a requirement to generate .csv file from abap report.
    Currently user saves data from abap report to spreadsheet(.xls format) in desktop.  Then opens excel file and save as .csv format.  Need option to save directly in .csv format instead of .xls format.
    Please let me know, if there is any standard function module available to create .csv file.
    Regards
    Uma

    I tried with your code it's going to dump
    REPORT ZTEMP101 message-id 00.
    tables: lfa1.
    types: begin of t_lfa1,
          lifnr like lfa1-lifnr,
          name1 like lfa1-name1,
          end of t_lfa1.
    data: i_lfa1 type standard table of t_lfa1,
          wa_lfa1 type t_lfa1.
    types truxs_t_text_data(4096) type c occurs 0.
    data: csv_converted_table type table of TRUXS_T_TEXT_DATA.
    select-options: s_lifnr for lfa1-lifnr.
    select lifnr name1 from lfa1 into table i_lfa1
           where lifnr in s_lifnr.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = ';'
             I_LINE_HEADER              =
             I_FILENAME                 =
             I_APPL_KEEP                = ' '
      TABLES
        I_TAB_SAP_DATA             = I_LFA1
    CHANGING
       I_TAB_CONVERTED_DATA       = csv_converted_table
    EXCEPTIONS
       CONVERSION_FAILED          = 1
       OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                  = ' '
      CODEPAGE                      = ' '
       FILENAME                      =
       'C:\Documents and Settings\ps12\Desktop\Test folder\exl.cvs'
      FILETYPE                      = 'DAT'
      MODE                          = ' '
      WK1_N_FORMAT                  = ' '
      WK1_N_SIZE                    = ' '
      WK1_T_FORMAT                  = ' '
      WK1_T_SIZE                    = ' '
      COL_SELECT                    = ' '
      COL_SELECTMASK                = ' '
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      TABLES
        DATA_TAB                      = csv_converted_table
      FIELDNAMES                    =
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_WRITE_ERROR              = 2
      INVALID_FILESIZE              = 3
      INVALID_TYPE                  = 4
      NO_BATCH                      = 5
      UNKNOWN_ERROR                 = 6
      INVALID_TABLE_WIDTH           = 7
      GUI_REFUSE_FILETRANSFER       = 8
      CUSTOMER_ERROR                = 9
      OTHERS                        = 10
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    my version is 4.6c

  • Stored Proc to create .csv file from table

    Hi all,
    I have a table with 4 columns and 10 rows. Now I need a stored proc to create a .csv file from the table data. Here the scripts to create a table and insert the row's.
    Create table emp(emp_id number(10), emp_name varchar2(20), department varchar2(20), salary number(10));
    Insert into emp values ('1','AAAAA','SALES','10000');
    Insert into emp values ('2','BBBBB','MARKETING','8000');
    Insert into emp values ('3','CCCCC','SALES','12000');
    Insert into emp values ('4','DDDDD','FINANCE','10000');
    Insert into emp values ('5','EEEEE','SALES','11000');
    Insert into emp values ('6','FFFFF','MANAGER','90000');
    Insert into emp values ('7','GGGGG','SALES','12000');
    Insert into emp values ('8','HHHHH','FINANCE','14000');
    Insert into emp values ('9','IIIII','SALES','20000');
    Insert into emp values ('10','JJJJJ','FINANCE','21000');
    commit;
    Now I need a stored proc to create a .csv file in my local location. Please let me know If you need any other details....

    Some pointers:
    http://www.oracle-base.com/articles/9i/GeneratingCSVFiles.php
    http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
    also, doing a search on this forum or http://asktom.oracle.com will give you many clues.
    .csv file in my local location.What is your 'local location'?
    A client machine? The database server machine?
    What database version are you using?
    (the result of: select * from v$version; )

  • Create csv file for data in tables

    Hi All,
    I need to "export" data for about 60 tables in one of my databases to a csv file format using a "|" as a separator.
    I know I can do this using a query like:
    select col1 || '|' || col2 || '|' || col3 from table;
    Some of my tables have more than 50 columns so I'm guessing there is an easier way to do this than to construct select SQL statements for each table?
    Thanks in advance.

    I would point out that the OP did not identify the target for the files so it could be an non-Oracle database or Excel in which case external tables would not work since Oracle only writes to external tables in datapump format.  If the target is another Oracle database then external tables would be an option.  If external tables are an option then insert/select over a database link would be a potential alternate approach to using csv files.
    I use a SQL script to generate the Select statement to create my csv files.
    set echo off
    rem
    rem SQL*Plus script to create comma delimited output file from table
    rem
    rem 20000614  Mark D Powell   Automate commonly done task
    rem
    set pagesize  0
    set verify    off
    set feedback  off
    set linesize  999
    set trimspool on
    accept owner    prompt 'Enter table owner => '
    accept tblname  prompt 'Enter table name => '
    spool csv2.sql
    select 'select ' from sys.dual;
    select decode(column_id,1,column_name,
                 '||''|''||'||column_name)
    from   sys.dba_tab_columns
    where  table_name = upper('&&tblname')
    and    owner      = upper('&&owner')
    order by column_id;
    select 'from &&owner..&&tblname;'
    from   sys.dual;
    spool off
    undefine owner
    undefine tblname
    HTH -- Mark D Powell --

  • Function moduls to create csv-file and send it per mail

    Hello,
    we have the following requirement.
    We created an eventhandler.
    Inside this eventhandler we built up an internal table with 1-n entries.
    Now we want to create a csv-file or excel-file in background and send it to the users mailadress.
    Are there standard function modules which we can use for this requirement.
    We can´t download the file directly to the users client with cl_gui_frontend_services because we are not in SAP GUI but in CRM Webclient UI.
    Thank you
    Best regards
    Manfred

    hello,
    thank you.
    a coding example would be very helpfull.
    the internal table shall be added as csv-attachment to the mail and the recipient shall be the current user.
    Thanks a lot in advance.
    Kind regards
    Manfred

  • Create CSV file through a program in background

    Hello everyone!
    I'm facing a problem using class CL_GUI_FRONTEND_SERVICES to generate a csv file.
    I have a report in SCM that will export data from APO to some csv files.
    At this moment I'm using GUI_DOWNLOAD method, it works perfectly! The problem is that this program is supposed to run in a background job, and as far as I read and searched for it.. GUI_DOWNLOAD and GUI_UPLOAD are not supposed to run in bakcground because of a "client-server" problem... well.. ok...
    So... I tried with the "OPEN DATASET" and it worked fine also, but now comes another issue: the "open dataset" method only writes/reads files located in the system server(is that right?)... and my file will be located on another location in the intranet.
    What should I use to generate this csv files in a background job!?
    Thanks,
    Martin

    there isn't a "client-server" problem...background jobs have no connectivity to a gui/presentation server and therefore no ability to upload/download to a desktop target....
    You can save, as noted, to any server visible to the SAP instance you're executing on.  I would recommend that you look at a multi-step process....
    create your internal table
    store that internal table in a file on your apps server (comma-delimited is okay, but tab-delimited would be much better choice)
    if you need to place the file where another system can access,
    utilize FTP capability in SAP to "copy" or "send" that file to an FTP target, after you have successfully written the file to the APPS server.
    If the file can be retrieved by a SAP user,
    write or utilize an existing piece of code to grab the file, upload into SAP and then utilize GUI_DOWNLOAD to transfer to the user's desktop target.
    This allows you to have both a background process, but have the file accessible to an SAP user after the file has been created.  I have several processes that do this and retrieval by the user is both easy and convenient, since the user is notified by my background job that the file has been created, etc.

  • 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

  • Dynamicall create csv files and zip them

    Apex version - 4.2
    I have some data in the database. I want to generate multiple csv files dynamically from those data. Then zip the csv files together to provide it to the end user.
    Can anybody suggest with the approach that could be followed.
    Thanx in advance !

    Find some code to generate the csv, for instance Export and save result set in CSV format using UTL_FILE
    Find some code to zip the files/blobs, for instance http://technology.amis.nl/2010/06/09/parsing-a-microsoft-word-docx-and-unzip-zipfiles-with-plsql/
    Combine the two pieces
    Done

  • APD creates CSV file as soon as it is executed altough the CSV is last step

    Hi,
    I have an APD with three steps:
    1. read a query
    2. remove records with figures = 0
    3. generate a CSV file
    As soon as the APD is executed the CSV file is generated. However it needs 5 minutes at least to really execute the query (step1 & 2) and fill in the file. The 'Open dataset' statement seems to be executed to soon in the APD execution.
    It bothers me as APD is scheduled based on an event. Another Abap program is also scheduled on the same event. This Abap checks regularly the delivery of the file in order to process it. So this Abap runs also too soon and does not process anything as the file is empty...
    Regards,
    Laurent

    Hi,
    At the time of saving file it will ask file path where to save   in work directory , just copy that path & search in AL11 .
    Before that make sure :
    1. in Data target Tab write data to app server must be selected  & in Write mode : check once either creatre file again if already overwrite.

  • I am having a problem creating a CSV file

    I have created CSV files and imported them into Mac's contact book before. For some reason this time its not allowing me to import them because its giving me this message: TEXT FILE IMPORT FAILURE "The selected file does not appear to be a valid comma separated values (csv) file or a valid tab delimited file. Choose a different file."
    The text when I copy paste it even comes out deliniated and everything.
    <Emails Edited By Host>

    Hi,
    You need to quote your path.
    Import-Csv 'C:\Scripts\PowerShell Scripts\newusers.csv'
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Not able to write image in csv file

    I have tried to write JPEG file in csv but having a critical probem.
    The JPEG in the CSV is coming wrongly. Means whenever I open the created CSV file I can see the image has been moved upside down.
    Can any one please help me how to write a proper image using ClientAnchor?
    Can anyone please provide any sample code
    Edited by: 837718 on Feb 17, 2011 6:25 PM

    Try this
         Workbook workBookObject= new HSSFWorkbook();
         Sheet sheet = wb.createSheet();
         CreationHelper helper = wb.getCreationHelper();
         Drawing drawing = sheet.createDrawingPatriarch();
    ByteArrayOutputStream img_bytes = new ByteArrayOutputStream();
                   int b;
                   while ((b = fis.read()) != -1)
                        img_bytes.write(b);
                   fis.close();
                   helper = workBookObject.getCreationHelper();
                   ClientAnchor anchor = helper.createClientAnchor();
                   int picIndex = workBookObject.addPicture(img_bytes.toByteArray(),Workbook.PICTURE_TYPE_JPEG);
                   anchor.setCol1(col);
         anchor.setRow1(0);
                   anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
                   pic = drawing.createPicture(anchor, picIndex);
                   pic.resize();

  • How to write the char value as is in the CSV file

    Hi Everyone,
    I am creating csv files which contains inventory details for all the products. I am able to create the csv file with utl file concepts. My problem starts after the csv file is being created.
    some of the product numbers(Though I am saying Product number, it is varchar2 data type in the table) is like this 3E-12, 3E-54 and so on. I have totally 23 product numbers like this.
    When the user opens the csv file it is changing to numbers like this 3.00E-12, 3.00E-54. I want to keep the product number as it is like char value. I tried many quoting and concat methods.
    But none of them works for me.
    I am using oracle 9i.
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.7.0 - Production
    Please help me to solve this problem.
    Thanks in advance,
    Vimal...

    Hi Friends,
    Thanks for the immediate response. Here is my code.
    CREATE OR REPLACE PROCEDURE DATA_TO_CSV_FILE
    IS
    l_file_ptr UTL_FILE.file_type;
    l_hdr_text VARCHAR2 (4000);
    l_dynamic_sql_str VARCHAR2 (4000);
    TYPE l_dynamic_sql IS REF CURSOR;
    l_dynamic_cursor l_dynamic_sql;
    l_org_id_select VARCHAR2 (200);
    l_master_org_id NUMBER;
    l_category VARCHAR2 (40);
    l_itemno VARCHAR2 (40);
    l_description VARCHAR2 (240);
    l_brand VARCHAR2 (240);
    l_organization_id NUMBER;
    l_oh NUMBER;
    l_status apps.mtl_system_items.inventory_item_status_code%TYPE;
    BEGIN
    l_file_ptr := UTL_FILE.fopen ('CSV_DIR', 'inventory.csv', 'w');
    l_dynamic_sql_str :=
    'SELECT mc.segment2 CATEGORY, itm.segment1 itemno '
    || 'itm.description description, LOG.brand brand,'
    || 'NVL (m.oh, 0) oh'
    || '(select msi.inventory_item_status_code from apps.mtl_system_items msi'
    || ' where msi.inventory_item_id = itm.inventory_item_id'
    || ' and msi.organization_id = '
    || l_master_org_id
    || ' ) status '
    || ' FROM xxx_custom_table m,'
    || ' apps.mtl_item_categories ic,'
    || ' apps.mtl_categories_b mc,'
    || ' apps.mtl_system_items itm,'
    || ' xxx_custom_table1 LOG,'
    || ' xxx_custom_table2 cap'
    || ' WHERE m.item_id(+) = itm.inventory_item_id'
    || ' AND m.org_id(+) = itm.organization_id'
    || ' AND itm.segment1 = cap.itemno(+)'
    || ' AND itm.inventory_item_id = ic.inventory_item_id'
    || ' AND itm.organization_id = ic.organization_id'
    || ' AND ic.category_id = mc.category_id'
    || ' AND mc.segment2 IS NOT NULL'
    || ' AND itm.inventory_item_id = LOG.inventory_item_id'
    || l_org_id_select
    || ' GROUP BY mc.segment2,'
    || ' itm.segment1,itm.inventory_item_id,itm.description,'
    || ' LOG.brand,LOG';
    OPEN l_dynamic_cursor FOR l_dynamic_sql_str;
    LOOP
    FETCH l_dynamic_cursor
    INTO
    l_category, l_itemno, l_description, l_brand, l_status,l_oh;
    EXIT WHEN l_dynamic_cursor%NOTFOUND;
    UTL_FILE.put_line (
    l_file_ptr,
    l_CATEGORY
    || ','
    || l_itemno
    || ','
    || l_description
    || ','
    || l_status
    || ','
    || l_brand
    || ','
    || l_oh
    END LOOP;
    UTL_FILE.fclose (l_file_ptr);
    END;
    Hey damorgan,
    Can you please give me little more detail about your workaround method. I think I did the ODBC Connection Once for MS ACCESS database. I
    hope you are taking about the same method.
    Thanks
    Vimal....

  • Csv file as source in OBI

    Hi,
    I am trying to use a csv file as a data source for OBI Answers where I will be updating the csv file daily and want to see the changes on the front end.
    These are the steps I am doing:
    1) create csv file and save on local machine
    2) create ODBC connection with Microsoft Text Driver (.txt, .csv)
    3) directory selected for .csv and format defined (format: CSV Delimited, characters: OEM), columns "guess" and then columns appear in list
    4) In Admin Tool the .csv file/table is imported into physical layer (RPD offline)
    5) When data is viewed for table in admin tool then data shows up fine
    My issue is when I start the BI server and open the RPD online then try to view the data of the file in the physical layer then I get number of errors:
    [nqs error: 10058] A general error has occured
    [nqs error: 43093] An error occured while processing the EXECUTE PHYSICAL statement
    [nqs error: 16001] ODBC error state: IM006 code: 0 message: [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    [nqs error: 16001] ODBC error state: S1009 code: -1023 message: [Microsoft][ODBC Text Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides..When I stop the BI server and open the RPD offline and then try to view data from the RPD then it connects fine and the data shows up.
    Any thoughts on how I can resolve the issue so I can model the data on RPD online and create dashboards/reports from the csv file??
    MANY THANKS!

    Please see if the suggested solutions in these docs help.
    "FileNotFoundException", "Cannot create directory", "Access is denied", etc Messages Are Signaled When The ODI Agent Running As Windows Service Uses Files Over Mapped Or Unmapped Network Drives [ID 424703.1]
    ORA-28500: not a valid path via hsodbc over a mapped drive [ID 266187.1]
    UNABLE TO USE MS ACCESS DB AS OBIEE SOURCE [ID 963882.1]
    Error connecting to Microsoft Access Database [ID 492129.1]
    Troubleshooting Error "1021001: Failed to Establish Connection With SQL Database Server" and Error (1021013) "ODBC Layer Error" [ID 598887.1]
    Thanks,
    Hussein

Maybe you are looking for