Solved

Exporting a table data to csv file

Posted on 2012-04-03
9
680 Views
Last Modified: 2012-04-03
Hi,

I am having a stored procedure which creates a csv file and insets data into the file from the table.

one column of the table is a number(4) and it requires a formatting of hh:mm
I did that formatting and this table also has -ve values.

Like -23:59, -03:56 etc..

On exporting to CSV file, when opened in note pad or word pad, the records are written properly without any problem but on opening with excel file, there is a problem.

For the rows which should contain records like -23:59 etc it i showing #value and when i clicked on the #value, it shows =-23:59..which means it is taking that number as a formula.

I need to know how to overcome this problem, all i wanted is that -23:59 and similar records should be available as it is required.

Please help resolve(I am using UTIL file package to write the data to csv file)

Regards
0
Comment
Question by:neoarwin
9 Comments
 
LVL 5

Expert Comment

by:Billy Roth
ID: 37799903
you could try using another spreadsheet app that allows different csv delimiters such as openoffice.org calc.  setup pure comma delimiters and remove the "" text field quoted delimiters.  Do most of your data processing in a editor like notepad++ with regular expressions and such, and then open in openoffice calc.
0
 
LVL 17

Expert Comment

by:k_murli_krishna
ID: 37800355
1) While writing data to CSV file using UTIL file package, make sure for at least negative values to surround with string delimiter as double quotes (") on either side. Also, in between column/field values, add a comma (,) as delimter

2) If double quotes (") OR comma (,) are used by any chance in actual data, then use any other special characters like #, ~, ^ etc. to make the CSV & it's data to open up correctly in Excel workbook's sheet

3)  Always, it is better to use TextPad for opening CSV or DAT files. It has rich formatting features

All the best.
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 37800627
Make sure the data is stored as:  ="-23:39",="-03:56"

Then when you open it in Excel it will be seen as text.
0
 

Author Comment

by:neoarwin
ID: 37801177
@slightwv I tried doing this ="-23:39",="-03:56"

But now the csv file is not getting generated, when I tried .txt it is getting generated.

UTL_FILE.put_line (v_file,
                            v_sector
                         || ','
                         || v_division
                         || ','
                         || v_region
                         || ','
                         || v_cmpgn_nr
                         || ','
                         || v_cmpgn_yr
                         || ','
                         || v_biling_dt
                         || ','
                         || v_dispatch_dt
                         || ','
                         || v_reg_ord_zone_mgr_lmt_dt
                         || ','
                         || v_zone_mgr_reg_ord_blok_tm
                         || ','
                         || v_zone_mgr_comp_ord_blok_tm
                        );

 v_zone_mgr_comp_ord_blok_tm this column is what I am talking about.
I don't know why now even the csv file is not getting generated.

Please help
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37801201
>>I tried doing this ="-23:39",="-03:56"

How did you try it?  I don't see it in the code you posted.


Does v_zone_mgr_comp_ord_blok_tm contain a single value like -23:59 or does it contain the entire list?

If a single value:

...
|| '="' || v_zone_mgr_comp_ord_blok_tm || '"'
...

>>I don't know why now even the csv file is not getting generated.

Likely a trapped error in the exception handler.
0
 

Author Comment

by:neoarwin
ID: 37801231
900,Divisão Pantanal,NO ,3,2012,23-JAN-12,24-JAN-12,'' 00:00'','' 21:22'','' 22:33''

These are the records I am trying to insert but now csv file is not getting generated.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37801277
>>These are the records I am trying to insert but now csv file is not getting generated.

That does not show me how you are generating it...

I need to see the actual code you are using.

>>but now csv file is not getting generated.

It is likely because you are now getting some error in the code when you attempted to add the quotes and '='.

The code probably has an exception handler.

What changes did you make to the code?
0
 

Author Comment

by:neoarwin
ID: 37802064
@slightvw It is working :)
0
 

Author Closing Comment

by:neoarwin
ID: 37802071
Than you very much!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help converting some sql server sql to Oracle sql 9 72
statspack purge automate 7 53
Extract the first word (before the , ) 2 38
MULTIPLE DATE QUERY 15 49
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now