1

I'm using this unix script which it is fetching records in the form of csv. I have a SQL query used for this purpose. It contains below information

SET PAGESIZE 5000
SET COLSEP ","
SET LINESIZE 2000
SET FEEDBACK OFF
SET NEWPAGE NONE
SET UNDERLINE OFF

Is it due to PAGESIZE it is consuming more space?

The script returns 4MB of CSV(OBTM.csv) file whereas if I'm converting the same to (OBTM.xlsx) it is 48KB.

Kindly clarify my query

  • What 'unix' script? Is this bash, ksh, zsh what? Could you give us an example of the .csv and .xlsx files generated? How are you converting? Are you on Unix,Linux, which one? – terdon Sep 11 '13 at 12:34
  • @terdon I'm using Sun solaris Unix server which is ksh shell. I can't attach generated files. usppodivximf00(usoponshximf00):/vol01/sites/provisioning/IG> uname SunOS usppodivximf00(usoponshximf00):/vol01/sites/provisioning/IG> usppodivximf00(usoponshximf00):/vol01/sites/provisioning/IG> echo $0 -ksh usppodivximf00(usoponshximf00):/vol01/sites/provisioning/IG> – user3475 Sep 11 '13 at 13:02
  • Please postthe details on how you are converting to csv and to xlsx and, if possible, a sample of the two files, yes. Either edit your question to post a few lines of each file or use a service like pastebin.com. – terdon Sep 11 '13 at 13:07
  • Thanks for the script, however, that does not show the part where the csv and xlsx files are generated. If I understand correctly, that is being done by /vol01/sites/provisioning/IG/46762.sql or perhaps count.sh. Also, you might want to delete the email addresses from your script in pastebin to avoid SPAM. – terdon Sep 11 '13 at 14:45
1

Most likely, each field in each record is space-padded to the field width. We'd need to see the query but instead of select * from table, you may need

select rtrim(field1) || ',' || rtrim(field2) || ',' || rtrim(field3) -- ...

Alternately, run the csv file through a sed script to trim excessive whitespace:

sed -i 's/[[:blank:]]\+,/,/g' OBTM.csv
  • @ terdon thanks for providing the new information about pastebin. I 'm sharing the pastebin link here. pastebin.com/3sN3sDPR @glenn I will try removing space. Kindly have a view on the script – user3475 Sep 11 '13 at 13:40
  • @terdon/glenn ... I'm providing SQL query in this link...Kindly review and let me know if u need any information pastebin.com/pQnm4cRA – user3475 Sep 11 '13 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.