Is there a way to handle commas inside the data when generating a csv file from shell script?
I am extracting data via sql query and some of the data has commas. Output File must be csv and I cannot update the data in the db (as it is used by other application).
Example
table FavoriteThings
Sample Data
excerpt from code
Output needs to be
currently I get
which when imported into excel shows 4 columns for Kurt
Last edited by vbe; 01-24-2019 at 02:39 PM..
Reason: code tags
Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are
1. The Control file name(.ctl file)
2. The Data file name(.csv file)
Does anybody have an idea about it? :confused: (3 Replies)
TEST_HEME,"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1",CELL
when I split by
FS=","
then
$0=TEST_HEME
$1="SubNetwork=ONRM_RootMoR
$2=SubNetwork=ARNC1"
but I need this will be single value
"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1" (4 Replies)
Friends...This is the first time i am trying the report generation using shell script... any suggestions are welcome.
Is there a way to set the font size & color when i am exporting the data from unix shell script as a CSV file ?
The following sample data is saved as a .csv file in the... (2 Replies)
I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Hi Guys,
I am new to shell script.I need your help to write a shell script.
I need to write a shell script to extract data from a .csv file where columns are ',' separated.
The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Hi Guys,
I am new to shell script.I need your help to write a shell script.
I need to write a shell script to extract data from a .csv file where columns are ',' separated.
The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values.
Name, Address,... (7 Replies)
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)
Hi List,
I have a chunk of data like so:
User Account Control:
User Account Control:
User Account Control:
User Account Control:
Disabled
User Account Control:
User Account Control:
User Account Control:
Disabled
User Account Control:
User Account Control:
... (3 Replies)
i have data as below
123,"paul phiri",paul@yahoo.com,"po.box 23, BT","Eco Bank,Blantyre,Malawi"
i need an output to be
123,"paul phiri",paul@yahoo.com,"po.box 23 BT","Eco Bank Blantyre Malawi" (5 Replies)
Discussion started by: mathias23
5 Replies
LEARN ABOUT PHP
oci_fetch_object
OCI_FETCH_OBJECT(3)OCI_FETCH_OBJECT(3)oci_fetch_object - Returns the next row from a query as an objectSYNOPSIS
object oci_fetch_object (resource $statement)
DESCRIPTION
Returns an object containing the next result-set row of a query. Each attribute of the object corresponds to a column of the row. This
function is typically called in a loop until it returns FALSE, indicating no more rows exist.
For details on the data type mapping performed by the OCI8 extension, see the datatypes supported by the driver
PARAMETERS
o $statement
-A valid OCI8 statement identifier created by oci_parse(3) and executed by oci_execute(3), or a REF CURSOR statement identifier.
RETURN VALUES
Returns an object. Each attribute of the object corresponds to a column of the row. If there are no more rows in the $statement then FALSE
is returned.
Any LOB columns are returned as LOB descriptors.
DATE columns are returned as strings formatted to the current date format. The default format can be changed with Oracle environment vari-
ables such as NLS_LANG or by a previously executed ALTER SESSION SET NLS_DATE_FORMAT command.
Oracle's default, non-case sensitive column names will have uppercase attribute names. Case-sensitive column names will have attribute
names using the exact column case. Use var_dump(3) on the result object to verify the appropriate case for attribute access.
Attribute values will be NULL for any NULL data fields.
EXAMPLES
Example #1
oci_fetch_object(3) example
<?php
/*
Before running, create the table:
CREATE TABLE mytab (id NUMBER, description VARCHAR2(30));
INSERT INTO mytab (id, description) values (1, 'Fish and Chips');
COMMIT;
*/
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT id, description FROM mytab');
oci_execute($stid);
while (($row = oci_fetch_object($stid)) != false) {
// Use upper case attribute names for each standard Oracle column
echo $row->ID . "<br>
";
echo $row->DESCRIPTION . "<br>
";
}
// Output is:
// 1
// Fish and Chips
oci_free_statement($stid);
oci_close($conn);
?>
Example #2
oci_fetch_object(3) with case sensitive column names
<?php
/*
Before running, create the table with a case sensitive column name:
CREATE TABLE mytab (id NUMBER, "MyDescription" VARCHAR2(30));
INSERT INTO mytab (id, "MyDescription") values (1, 'Iced Coffee');
COMMIT;
*/
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT id, "MyDescription" FROM mytab');
oci_execute($stid);
while (($row = oci_fetch_object($stid)) != false) {
// Use upper case attribute names for each standard Oracle column
echo $row->ID . "<br>
";
// Use the exact case for the case sensitive column name
echo $row->MyDescription . "<br>
";
}
// Output is:
// 1
// Iced Coffee
oci_free_statement($stid);
oci_close($conn);
?>
Example #3
oci_fetch_object(3) with LOBs
<?php
/*
Before running, create the table:
CREATE TABLE mytab (id NUMBER, description CLOB);
INSERT INTO mytab (id, description) values (1, 'A very long string');
COMMIT;
*/
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT id, description FROM mytab');
oci_execute($stid);
while (($row = oci_fetch_object($stid)) != false) {
echo $row->ID . "<br>
";
// The following will output the first 11 bytes from DESCRIPTION
echo $row->DESCRIPTION->read(11) . "<br>
";
}
// Output is:
// 1
// A very long
oci_free_statement($stid);
oci_close($conn);
?>
SEE ALSO oci_fetch(3), oci_fetch_all(3), oci_fetch_assoc(3), oci_fetch_array(3), oci_fetch_row(3).
PHP Documentation Group OCI_FETCH_OBJECT(3)