Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to retrive data from DB(Aqua studio) in CVS format using UNIX script? Post 302780013 by DGPickett on Wednesday 13th of March 2013 04:17:48 PM
Old 03-13-2013
The first queston in csv solutions is "Does the data include char with comma or double quotes?"
  • If not, it never needs quoting or escapes.
  • In csv, embedded commas must be double-quoted and embedded double quotes must be doubled! For example, if a column contained ' We said "Hello, sailor!" ', then it needs to be ' "We said ""Hello, sailor!"" ' or even ' We said ""Hello"," sailor!"" ' (double quotes right around the comma)! Many double quote every column against commas, but most forget double quote doubling! In a C/C++/JAVA/PERL program, you can detect comma and only quote on need, whole column in case it has multiple commas, for a minimum file size. CSV is very compressible, too.
You can select into excel with odbc and save as csv!

You can select with any command line tool (isql from unixODBC, jisql for xigole w/JDBC) and use sed or awk to reformat it trimmed with comma separators.

If the tool has a column separator, you can set it to comma, or convert it to comma.

You can put the commas in your select: select col_a || ',' || col_b .... Sometimes the concatenated string exceeds the allowed length unless you break it up.

You can put a marker on the data lines so they are simple to detect and separate from headings, error reports and status:
Code:
echo "
 select 'dAtAq,' || col_a || ',' || col_b || ....
" | isql ... | sed -n '
  s/^dAtAq,//p
  t
  w logfile
 ' > xxx.csv

We could process in bash if you insist.

Last edited by DGPickett; 03-13-2013 at 05:31 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help to retrive data from log file

hi i have following file. where i m trying to retrive data on latest date. let us say we are extracting data from this file for Jun 30 where date is highest date in log file. here i want to take output in other file from first line of Jun 30 to the end of file in short i want retrive... (5 Replies)
Discussion started by: d_swapneel14
5 Replies

2. Shell Programming and Scripting

to retrive data that appear only once in a file.

hi, I need to get the list of functions that are used more than once in a file list. Thanks in advance (1 Reply)
Discussion started by: anibu
1 Replies

3. Shell Programming and Scripting

Shell script to format a .CSV data

Hi There I needed to write a Unix shell script which will pick up the data from a .CSV file and reformat it as per the requirement and write it to another .CSV file. Currently I am in the proess of Data Import to "Remedy System" (A one kind of incident mangement Application) and this... (8 Replies)
Discussion started by: Uday1982
8 Replies

4. UNIX for Advanced & Expert Users

shell script to format .CSV data

Hi all, I have written a shell script to search a specified directory (e.g. /home/user) for a list of specific words (shown as ${TMPDIR}/wordlist below). The script works well enough, but I was wondering if there was a way to display the line number that the word is found on? Thanks! cat... (1 Reply)
Discussion started by: tmcmurtr
1 Replies

5. Shell Programming and Scripting

Need script to format data specifically

Hi all, I need a script specially using loops to print below output... variables x, a and b will be read from user... x a b x+1 a b+1 x+2 a b+2 x+3 a+1 b x+4 a+1 b+1 x+5 a+1 b+2 for example.... 1 ... (4 Replies)
Discussion started by: swapniltathe
4 Replies

6. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

7. Programming

updating data in cvs file using c programming

hi every one i want to read and write data from cvs file using c program. but my problem is that at run time my data is increasing in both row wise and column wise. that means it is continuously updating in both direction. is there any way through which i can find the next colum or row for eg... (0 Replies)
Discussion started by: sajidtariq
0 Replies

8. Shell Programming and Scripting

Perl -- Script to re-format data

Hi, I have a file with data in the following format BOX -1.000000 -1.000000 0.000000 30.00000 14.00000 0.1000000 0.000000 0.000000 0.000000 0.000000 0.000000 CYLINDER 3.595000 2.995000 0.000000 0.5100000 2.000000 Z 0.000000 0.000000 0.000000 I want to convert these files... (1 Reply)
Discussion started by: lost.identity
1 Replies

9. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies
cscope-indexer(1)					      General Commands Manual						 cscope-indexer(1)

NAME
cscope-indexer - Script to index files for cscope SYNOPSIS
cscope-indexer [-v] [-f database_file] [-i list_file] [-l] [-r] DESCRIPTION
This script generates a list of files to index (cscope.out), which is then (optionally) used to generate a cscope database. You can use this script to just build a list of files, or it can be used to build a list and database. This script is not used to just build a data- base (skipping the list of files step), as this can be simply done by just calling "cscope -b". Normally, cscope will do its own indexing, but this script can be used to force indexing. This is useful if you need to recurse into sub- directories, or have many files to index (you can run this script from a cron job, during the night). It is especially useful for large projects, which can contstantly have source files added and deleted; by using this script, the changing sources files are automatically handled. Currently, any paths containing "/CVS/" or "/RCS/" are stripped out (ignored). OPTIONS
-f database_file Specifies the cscope database file (default: cscope.out). -i list_file Specifies the name of the file into which the list of files to index is placed (default: cscope.files). -l Suppress the generation/updating of the cscope database file. Only a list of files is generated. -r Recurse into subdirectories to locate files to index. Without this option, only the current directory is searched. -v Be verbose. Output simple progress messages. SEE ALSO
cscope(1) AUTHOR
This manual page was written for the Debian GNU/Linux system by Robert Lemmen <robertle@semistable.com> (but may be used by others, of course) Script to index files for cscope 30. December 2002 cscope-indexer(1)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy