Query on formating CSV file.
Hi All,
According to my business logic i need to read data from DataBase and need to create CSV file to represent that data. I am able to create CSV file. But i want to format the cells of the CVS file. means like, i want to change the back groung color of a cell. Is it possible to do changes to the cells of CSV file through JAVA program?.
Regards,
Naga.
A CSV is, as definition, a comma separated values format.
It can contain only text and you cannot give any formatting definition, neither via Java nor via an editor.
Similar Messages
-
Hi,
I am trying to export a Query result to CSV in comma-delimited tab format.
In SBO it is allowing to save the query results as CSV file; but when I opened
it is in 'Text Unicode' filetype.
Is there anyway save it directly as CSV in comma-delimited tab format.
Thanks Regards
ShivaHi Gordon,
Sorry could not reply soon.
Its a smiple query
"SELECT ItemCode, ItemName, ItmsGrpNam,
LeadTime, VATLiable, CardCode"
The things is we might make some changes to it based on customer requirement. But the fact is no matter what query, I have no problem with query. It is while saving it is making a 'tab-delimited' file rather than 'comma-delimited file'. User has to manually open it and save it as CSV file.
Regards
Shiva -
How to Export BW Query Report to .csv file
I try to export BW QueryReport to .csv file using ReportAgent and URL command in WEB Template:
<SAP_BW_URL DATA_PROVIDER='VIEW1' CMD='EXPORT' FORMAT='CSV'>
but can't find the result file.
Is someone have experience in exporting BW Reports to file in automatic way?Another way to do it would be to use transaction RSCRM_BAPI.
Not ideal for large volumes but allows you to extract from a query.
Regards,
Mike -
Export query results into .csv file?
Hello I have a T-SQL script that gets row counts for a specified date range and then needs to loop (by incrementing +1 day to get the next day's counts) for a large date range. I'm aiming to output & append each query results day counts
into a .csv file via a SQL Agent job since this will take quite a while to complete.
Would using the following as an example template...
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\;HDR=YES;FMT=Delimited','SELECT * FROM [FileName.csv]')
SELECT Field1, Field2, Field3
FROM DatabaseName
...be the method or something else?
If this is good to use I've tried running this but get the following error:
Msg 7357, Level 16, State 2, Line 76
Cannot process the object "SELECT * FROM [FileName.csv]". The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions
on that object.
Thanks in advance.Hi Techresearch7777777,
The error in your post says that the file FileName.csv has to be created with the column names in the first row. Like:
Field1,Field2,Field3
Either you can create a schema.ini file under the same folder:
[FileName.csv]
Format=CSVDelimited
ColNameHeader=False
Col1=Field1 [DataType]
Col2=Field2 [DataType]
Col3=Field3 [DataType]
For the [DataType],you can reference
Schema.ini File (Text File Driver)
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Sql query to downloaded csv file
Hi.
This is probably something really easy, but I cant find how to do it.
I want to run a dynamic SQL query and have the output appear in csv format as a file the user can save to disk.
Is this easy, if so how? Or is there a longer packaged based solution to this?
Regards,
AsimAsim,
First you need to create a report, you can use a simple SQL query based report, or if your query is dynamic, use a region of type PL/SQL function returning SQL query. Then go to the reports attributes page and enable the CSV link for that report. When running your report page, youâll notice a CSV export link that lets your download your report as a CSV file.
Alternatively, If you donât want to run the report as a regular HTML DB page at all, then you could just choose the CSV template as the report template on the reports attributes page. When running the page with that template, it opens a file download dialog for the CSV file right away. You could integrate this with your own application by placing a âdownloadâ button on some other page, that on clicking of this button branches to the CSV download page and by doing so, lets you download the file.
Marc -
Inserting a satment that allows otpu of a query to a CSV file
Hi,
I have have been informed that a UTL file will not be required. A simple CSV file is all that is wanted.(Pass the results of the select clause into the csv).
So can anyone help me place such a command into the below script, where the results of the select clause can be sent to a CSV file.
Thanks.
declare
from_date DATE :='09-dec-2007';
to_date DATE :='22-dec-2007';
cursor date_range is
select a.Item_ID , b.shipnode_key, b.quantitY as ONHAND
from YFS_INVENTORY_ITEM a, YFS_INVENTORY_Supply b
where b.Supply_TYPE = 'ONHAND'
and b.Inventory_item_key = a.Inventory_item_key;
begin
l_output := dbms_output.put.fopen('Stock_Mirroring',' YFS_INVENTORY_ITEM a, YFS_INVENTORY_Supply b||to_date||.csv','w');
for l_count in date_range loop
dbms_output.put_line(l_output,
l_count.a.Item_ID||'|'||
l_count.b.shipnode_key||'|'||
l_count.b.quantitY);
end loop;Outputting to a CSV file - responses should stay in that thread.
-
Hi,
By using Query (SQ01), we are able to download data in Excel format, Text format, etc. But... is there an option that I can download in CSV format.
Thanks.....
Rgds,
KianHi Kian,
you could save the Excel file in CSV format, couldn't you?
Regards
Bernd -
Saving jsp query results to csv file
I have a query form jsp application which does as you would expect - throw in some search parameters - results set is returned - my question is how I go about writing an instance to save these results into a csv notepad file. I've used JBuilder a lot and within that it is relatively simple to create a save-to-file instance - is it the same within JDeveloper?? Sorry if this is a fairly obvious question - I just havent come across anything in the docs yet
Try this in a JSP:
<%
response.setContentType( "text/x-csv" );
response.setHeader( "Content-disposition", "inline;filename=myfilename.csv" );
%>
"value1","value2","value3"
"valueX","valueY","valueZ" -
Hi,
Is there a way to execute the query and save it in application server as csv format . I've aleardy tried couple of the options -
RSCRM_BAPI - due to complex restrictions in the query, the output is not consistant.
Information Broadcasting - can either store in KM folder(portal) or email, not in application server.
I have gone thro the couple of forum threads wr - abap to csv(Execute BW query using ABAP Part III), writequery, RRW3_GET_QUERY_VIEW_DATA .. The abap with direct output to application server will be interested.
Thanks
SreedhHi,
I hope it will help.
Exporting as a CSV File
In order to process a query executed in a Web application further, you have to export the query as a CSV file or MS Excel 2000 file.
Prerequisites
· You have executed a query in your Web application and want to display it in a different format and continue processing the query.
· To export the data to an Excel file, you have opened the BEx Analyzer
Procedure..
1. From the context menu (left mouse-click on the text of a characteristic, characteristic value, structural component, description of exception, description of condition), choose Export As.... ® CSV File or Export As.... ® MS Excel 2000 File. The system exports the data into a CSV file or an MS Excel 2000 file.
Export to MS Excel files from MS Excel 2000 is supported.
2. If you choose Export As...® CSV File, the query is displayed in CSV format (comma separated value). The numerical values of the query are displayed in a list that is separated with commas. The numerical values context, formatting (for example, displaying exceptions) and the filter data are available in the CSV file. You cannot navigate further with BW functions.
Thanks
Hema -
Save as file format CSV in Excel
Does anyone know the correct syntax on this one?
I have an excel file which should be saved as CSV.
This is what I came up with, but it doesn't run.
tell application "Microsoft Excel"
activate worksheet "worksheet1"
set fileSaveName to get save as file format CSV file format filename
save as filename fileSaveName
if fileSaveName is not "" then
display dialog "Save as " & fileSaveName
end if
end tellIt's not surprising it doesn't run but that's not entirely your fault. Excel has pone of the funkiest dictionaries around - I think they forgot to read the AppleScript Implementor's guide and instead tried to bolt VB on instead.
Anyway, I digress...
I'm not sure what you expect this line to do:
set fileSaveName to get save as file format CSV file format filename
but it's completely invalid. For one, save as is a command verb, not a function, so you cannot get save as.
If you read the dictionary for Excel's save as command you'll find:
save as sheet ¬
filename unicode text ¬
file format as ¬
password unicode text ¬
write reservation password unicode text ¬
read only recommended boolean ¬
create backup boolean ¬
add to most recently used list boolean ¬
overwrite boolean ¬
save as local language boolean
so the first, required, parameter is the sheet to save followed by any number of the optional parameters. Given the above, I'd expect your script to look more like:
tell application "Microsoft Excel"
save as worksheet "worksheet1" file format CSV file format filename "whatever.csv"
end tell
which is completely bass-ackwards, if you ask me, but that's how it goes. -
Export query results to a CSV file
Hi,
My requirement is I need to export the results of a query to a CSV file. Can anyone please suggest a way to include the column names also in the CSV file?
Thanks in advance.
AnnieFollowing code is from asktom. I have modified to include column heading. This will get your desired CSV file for a given query.
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
l_colDesc dbms_sql.DESC_TAB;
begin
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 );
l_status := dbms_sql.execute(l_theCursor);
dbms_sql.describe_columns(l_theCursor,l_colCnt, l_colDesc);
l_separator := '';
for lColCnt in 1..l_colCnt
loop
utl_file.put( l_output, l_separator || '"' || Upper(l_colDesc(lColCnt).col_name) || '"');
l_separator := p_separator;
end loop;
utl_file.new_line( l_output );
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i,
l_columnValue );
utl_file.put( l_output, l_separator || '"' ||
l_columnValue || '"');
l_separator := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;The original link is below.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:95212348059
Thanks,
Karthick. -
How to get sql query data and write into csv file?
I am writing to seek help, in how can I create bat. script which can execute the following logic:
connection to the database
run sql query
create CSV file
output query data, into CSV file
save the CSV file
osql
-S 84.18.111.111
-U adw
-P rem
-i "c:\query.sql"
send ""
sed -e 's/,\s\+/,/g' MCI_04Dec2014.csv > localNoSpaces.csv
-o "c:\MCI_04Dec2014.csv"
This what i have so far, and I am little struggling with the logic after creating CSV file. I am unable to get the above script to work, please advice further, where I may be going wrong.
Can you create if statement logic within window's script, to check for null parameters or data feeds?
Any hints would be most appreciated.Thank you for your reply.
Apology for posting the code irrelevant to the forum, as I am still novice scripting user.
My goal is to create window's script which can compute the above logic and send the final output file (csv), to FTP folder.
Can this logic be implemented via bat. script, if so, is there a example or tutorial i could follow, in order to achieve my task.
Any help would be much appreciated. -
Saving result from query into CSV file
Hi folks,
in our application we're generating pages source using general packages (like htp, owa_util, ...). and in this part I'm a really beginner.
I want to modify source one of our page, I want to add functionality to enable save result from query (cursor) into CSV file, to enable user choose place where generated file will be created and also change file name.
I searched this forum and I found procedure, that could be useful:
procedure p_getcsv is
cursor cur is
select 'a1' col1, 'b1' col2, 'c1' col3 from dual
union select 'a2' col1, 'b2' col2, 'c2' col3 from dual
union select 'a3' col1, 'b3' col2, 'c3' col3 from dual;
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="test.csv"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in cur
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn(x.col1||','|| x.col2||','||x.col3|| chr(13));
end loop;
end;What peace of code should I add to procedure that is generating web page to enable calling this procedure and whole saving process?
Can anybody help me with this?
Many thanks,
Tomas
Message was edited by:
TomeoHi Marc,
thanks for reply, problem is that I'm not using APEX application, I'm just generating web page code straight using oracle general packages.
But I found this solution (maybe some tunning will be good):
In page where I want to display Download i have
begin
htp.anchor2 (
curl => ... .p_getcsv'||'?term=2005&crn=123,
ctext => 'Download Class List'
HTP.br;
end;
...si I'm calling p_getcsv procedure:
procedure p_getcsv( term IN stvterm.stvterm_code%TYPE DEFAULT NULL,
crn IN sirasgn.sirasgn_crn%TYPE DEFAULT NULL) is
v_length NUMBER;
v_file_name VARCHAR2 (2000);
temp_blob blob;
line RAW(32767);
begin
DBMS_LOB.CREATETEMPORARY(temp_blob, TRUE);
FOR i IN 1..6 LOOP
line := UTL_RAW.CAST_TO_RAW(i||','||term||','||crn||',AAA,BBB,CCC'||chr(10));
DBMS_LOB.WRITEAPPEND(temp_blob, LENGTH(UTL_RAW.CAST_TO_VARCHAR2(line)), line);
END LOOP;
v_file_name := 'ClassList.csv';
v_length := DBMS_LOB.getlength (temp_blob);
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
OWA_UTIL.mime_header (NVL ('csv', 'application/octet'), FALSE);
-- set the size so the browser knows how much to download
HTP.p ('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
HTP.p ( 'Content-Disposition: attachment; filename="'
|| REPLACE (REPLACE (SUBSTR (v_file_name,
INSTR (v_file_name, '/') + 1
CHR (10),
NULL
CHR (13),
NULL
|| '"'
-- close the headers
OWA_UTIL.http_header_close;
-- download the BLOB
WPG_DOCLOAD.download_file (temp_blob);
-- release temporary blob
dbms_lob.freetemporary(temp_blob);
end;Regards,
Tomas -
Exporting query results into a csv file using arabic and hebrew chars
Hi,
iv'e encountered a problem, using plsql to export a query into a csv file.. the arabic turns into question mark. Do you have any idea why?Usually this indicates a mismatch between client and database character set.
How do you export this query?
What is your database version?
What is your client OS?
T. -
Hi all,
I am currently planning to develop a program that does the following things:
1. Connects to the Oracle database
2. Runs a query
3. Export the results of the query to a CSV file in a folder
If theres anyone out there who has experienced in similliar work, please explain to me with codes as example or point to me tutorials.
cheers
SIjwenting wrote:
johndjr wrote:
jschell wrote:
johndjr wrote:
DrClap wrote:
Of course there are people who can't tell the difference between a CSV file and an Excel spreadsheet.And a good thing I say. I deal with a number of people who love their spreadsheets. I can create a simple CSV file and when they double click on it on Windows, Excel opens a spreadsheet and we are both happy.I bet they would be happier if it was a real spreadsheet.You would almost certainly win that bet.I doubt many of them would even notice :)++
Maybe you are looking for
-
In preview how can i create an hyperlink annotation
I've upgradetd to mountain lion and i'd like to create a Link annotation on my PDF using Preview, but i cannot find the right tool The Help says: Click Annotate in the toolbar, if you don't see the annotations bar. Click Link in the annotations bar.
-
Update file date/time stamp using java
Let me explain you what I am going through:- I have created a java based installer using Jexpress tool and after I do the installation of my files, the files takes the current date rather then taking the date when it was created or modified. Everythi
-
When I modify a file, and upload it to the remote server, I lose all undo capabilities. So if the change I made broke something, im screwed. I have the same version of dreamweaver on 2 other pcs, and 1 other mac, and do NOT have this issue. I had
-
Spilled water on my MacBook Pro. What do I do?
I spilled water on my 2010 MacBook Pro the other night. I immediately turned it off, drained the water out of the keyboard and dried the laptop. I tried turning it back on and got the apple startup white screen, but would freeze and not go anywhere.
-
Hi, We are planning to move to SSL based communication for our web based application as well as internal communication between various components using Sockets. Are there any studies done, which tell us about the performance impact of using SSL. How