[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Messages posted by: hansley
Forum Index » Profile for hansley » Messages posted by hansley
Author Message
I had the need, so just hacked this out and wanted to save others the pain. These two chained sed scripts will delete the header and footer rows, clean out the 1> bits, get rid of the line between the header and first data row, get rid of all extra whitespace, change pipes to ",", add " to the front of each line, and clean up ugly line endings. The only thing to change is to change ColHeadOne to whatever your first column header is. It dependes on your jisql output being named 'interim_results.csv'.

sed -e 's/^\x0D$//g' \
-e '/^$/d' \
-e '1,2d' \
-e '4d' \
-e '3s/^.*ColHeadOne/ColHeadOne/g' \
-e 'N;$!P;$!D;$d' < interim_results.csv | \
sed -e 's/ */ /g' \
-e 's/ *| */","/g' \
-e 's/^ */"/g' \
-e 's/,"*$//g' > final_results.csv

Enjoy. No warranties, expressed or implied. Your mileage may vary. No whales were harmed in the production of this script. Please recycle when done with it.
-Bill

 
Forum Index » Profile for hansley » Messages posted by hansley
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle