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
CVS-AUTORELEASEDEB(1)					User Contributed Perl Documentation				     CVS-AUTORELEASEDEB(1)

NAME
cvs-autoreleasedeb - Automatic Release of debian packages from CVS DESCRIPTION
This script generates and uploads the debian package for cvs modules managed by cvs-buildpackage. cvs-autoreleasedeb will maintain a state file of all the packages you want to be automatically published, and every time you commit the debian/changelog file of your package, changing the debian version to a greater value, it will be published. All the parameters to the script are configured in the conffile. There is no command-line switch. See cvs-autoreleasedeb.conf(5) for more information. USING
There are two ways of using this script: 1) Run as user cvs-autoreleasedeb in cron. This is very useful for software houses that want to have the "nightily build" version of the software published automatically. In this case, the config file will be "/etc/cvs-autoreleasedeb.conf" and it will use /var/lib/cvs-autoreleasedeb/ as scratch dir. NOTE: edit /etc/default/cvs-autoreleasedeb to control this behavior NOTE 2: all output will be thrown in /var/log/cvs-autoreleasedeb/run.log 2) Run as yourself, it will automatizate the work you will have if you have your packages in CVS. In this case, the config file will be $HOME/.cvs-autoreleasedeb/conf and the scratch dir will be $HOME/.cvs-autoreleasedeb. cvs-autoreleasedeb will not create defaults, you must have the configuration file created before running cvs-autoreleasedeb. See cvs-autoreleasedeb.conf(5). TODO
- Use a snapshot of the time of the commit in the changelog to checkout the source - Localize the messages. - Work with other than all lowercase in conffile. - Use a better format for conffile. _EXIT CODES _exit codes: 0 = Clean _exit 1 = Config file not found 2 = No packages in config file 3 = Couldn't open the state file 4 = Couldn't open the state file for writing 5 = Couldn't determine architecture SEE ALSO
cvs-buildpackage(1), cvs(1), cvs-autoreleasedeb.conf(5), dupload(1) AUTHOR
This manual page was written by Daniel Ruoso <daniel@ruoso.com>, for the Debian GNU/Linux system. perl v5.8.7 2006-08-04 CVS-AUTORELEASEDEB(1)
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy