UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old January 18th, 2005, 08:10 AM
rudz rudz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 rudz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face grabbing data from columns

i really need some help here, have been asked to write a shell script to grab data from a report, please find attached a sample report that i need to work on, could somebody please tell me how to grab say data from column "Book Value" ?? , i don't know how to get rid of the header above the column headings, please suggest the best approach to solve this problem, any help is greatly greatly appreciated
Attached Files
File Type: txt report.txt (4.8 KB, 383 views)

Reply With Quote
  #2  
Old January 18th, 2005, 09:24 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,077 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 13 h 40 m 11 sec
Reputation Power: 8
not really easy
the output file is not constant, not structured
assumin you are on *nix, 'cut' and 'sed' can help you
a) try a position guess, it seem to be constant
' 40,213.03 JAPANESE YEN 1.00'
the length of this string give (maybe) the start pos of the required value
cut -cX,Y filename
where X is strlen of that string and Y is max len of expected output
then pipe this to sed, purging all spec char like spaces,(),komma, punct and so on
cut -cX,Y filename ¦ sed 's/[,\.()]//g;s/ [ ]*$//;s/ [ ]*//g/'
i explain the sed, remember the X Y values are IMPORTANT
a) take off all punctiation and ()
b) kill AT END all spaces
c) kill AT BEGIN all spaces
NOT TESTED, just a guess

Reply With Quote
  #3  
Old January 18th, 2005, 10:24 PM
rudz rudz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 rudz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you very much for your reply , have been asked to use awk tho, any insights anybody

Reply With Quote
  #4  
Old January 19th, 2005, 03:48 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 116 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 34 sec
Reputation Power: 6
Quote:
Originally Posted by rudz
thank you very much for your reply , have been asked to use awk tho, any insights anybody



I have no time to study the structure of your file, but if I were you, I would try to write a script that prints out specified lines and specified columns. "KISS" - keep it stupid and simple. It is at least the first approach. Try this:

:
[ $# -eq 4 ] || {
echo "$0: call $0 first_line last_line col_start col_end" >&2
exit 1
}

awk '
NR>='$1' && NR <='$2' {print substr($0, '$3', '$4'-'$3'+1)}
'

Use copy and paste, all these sily apostrophes are significant. Send standard input into the script.

Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > grabbing data from columns


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway