Script to compact information !


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to compact information !
# 8  
Old 11-15-2009
Hello rdcwayx and Everybody,

How can I add a filter to the data for ignore the rows of Sundays before or after to process data with the shell script.

Thanks in advance.

Carlos
# 9  
Old 11-16-2009
Code:
awk -F, '{
{date[$3]=$3}
{if (open[$3]=="") open[$3]=$5}
{if (high[$3]<$6) high[$3]=$6}
{if (low[$3]=="") low[$3]=$7}
{if (low[$3]>$7) low[$3]=$7}
{closep[$3]=$8}
{vol[$3]+=$9}
}
END {for (i in open) {print "EUR_USD,D",date[i],open[i],high[i],low[i],closep[i],vol[i]}}
' OFS="," EUR_USD-1H.txt |sort -t, -k3r |awk -F, '"date -d "$3" +%a"|getline out {if (out!="Sun") print}'

This User Gave Thanks to rdcwayx For This Post:
# 10  
Old 12-02-2009
Hello rdcwayx and Everybody again,

I need your help with an additional filter in order to use another tool for make charts.

So I need to create other output file with a change in the date field format as follow:

From
EUR_USD-USA,D,04/29/2009,1.3248,1.3339,1.3222,1.3251,8694
EUR_USD-USA,D,04/30/2009,1.3231,1.3278,1.3190,1.3226,7753
EUR_USD-USA,D,05/01/2009,1.3261,1.3278,1.3238,1.3265,3959

To
EUR_USD-USA,D,20090429,1.3248,1.3339,1.3222,1.3251,8694
EUR_USD-USA,D,20090430,1.3231,1.3278,1.3190,1.3226,7753
EUR_USD-USA,D,20090501,1.3261,1.3278,1.3238,1.3265,3959

Thanks in advance.

Carlos
# 11  
Old 12-02-2009
Code:
awk -F, 'split($3,a,"/") {print $1,$2,a[3]a[1]a[2],$4,$5,$6,$7,$8}' OFS=, urfile

This User Gave Thanks to rdcwayx For This Post:
# 12  
Old 12-02-2009
Code:
gawk -F"," '{ split($3,a,"\/") ; $3=a[3]a[1]a[2]}1' OFS="," file.txt

SmilieSmilieSmilieSmilie
# 13  
Old 12-13-2009
Hello rdcwayx and Everybody,

The shell script of convert the date from MM/DD/YYYY to YYYYMMDD working fine but it does not work when the date field does not have the 8 characters.
For this kind of files I would like to complete the field date in all rows to 8 characteres. I know that the command date -d +%D could help me with this purpose.


SPY,D,11/2/2009,104.13,105.41,103.08,104.32,254222900
SPY,D,11/3/2009,103.74,104.8,103.54,104.65,228362600
SPY,D,11/4/2009,105.51,106.33,104.65,104.92,247996700
SPY,D,11/5/2009,105.66,106.88,105.44,106.85,180015300
SPY,D,11/6/2009,106.26,107.4,106.05,107.13,170954100
SPY,D,11/9/2009,107.95,109.63,107.87,109.57,159495700
SPY,D,11/10/2009,109.31,109.93,108.97,109.59,171899800
SPY,D,11/11/2009,110.31,110.82,109.62,110.15,169466200
SPY,D,11/12/2009,110,110.57,108.75,109.03,157144500
SPY,D,11/13/2009,109.31,110.09,108.75,109.62,150963000
SPY,D,11/16/2009,110.38,111.69,110.32,111.21,210922200
SPY,D,11/17/2009,110.92,111.39,110.5,111.34,147134100
SPY,D,11/18/2009,111.26,111.43,110.57,111.27,156486800
SPY,D,11/19/2009,110.51,111.31,109.13,109.82,208734600
SPY,D,11/20/2009,109.25,109.76,109.01,109.43,134196000
SPY,D,11/23/2009,110.72,111.74,110.6,110.82,148010200
SPY,D,11/24/2009,111,111.2,110.01,110.99,138420100
SPY,D,11/25/2009,111.17,111.5,110.82,111.38,109564800
SPY,D,11/27/2009,108.4,110.32,108.29,109.57,126001800
SPY,D,11/30/2009,109.48,110.2,108.12,109.94,160874800
SPY,D,12/1/2009,110.92,111.66,110.73,111.3,159613700
SPY,D,12/2/2009,111.28,112.01,110.92,111.25,131331000


An example of the final output of the file could be

SPY,D,20091201,110.92,111.66,110.73,111.3,159613700
SPY,D,20091202,111.28,112.01,110.92,111.25,131331000

I really appreciate your help with a script for this issue

Carlos
# 14  
Old 12-13-2009
use below:-


Code:
gawk -F"," '{ split($3,a,"\/") ; if ( a[2] < 10) {$3=a[3]a[1]"0"a[2]}
else {$3=a[3]a[1]a[2] }}1' OFS="," file.txt

SmilieSmilieSmilieSmilie

Last edited by ahmad.diab; 12-21-2009 at 06:16 AM..
This User Gave Thanks to ahmad.diab For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compact script with array - Good idea?

Hi, I have a shell script where a lot of the code is repeated. I wanted to make the code much more compact so I spoke to a guy and he suggested using arrays, like follows: #!/bin/bash readonly -a nginx=('nginx' '--prefix=/opt' '-j 4' 'http://nginx.org/download/nginx-1.2.2.tar.gz' )... (2 Replies)
Discussion started by: Spadez
2 Replies

2. Ubuntu

Format a compact flash card in Ubuntu

I need some assistance formatting a compact flash card in Ubtunu. I connect up the CF card through a USB reader. Ubuntu recognizes the reader usb device, but does not "mount" the CF card as a device. The CF card was formatted in FAT32 format. Any help would be greatly appreciated.... (3 Replies)
Discussion started by: genesis211
3 Replies

3. Shell Programming and Scripting

Compact 3-D output from a big input like:

Hi Experts!!!! Tried a lot but in vein,no success, please help to achieve this LOGIC behind is first field is reffrance row field, the second field shoud be made titles of coulmn and the the third field is made as matrix value. And if they dont match the matrix value should be 0. (Unix (Shell,... (1 Reply)
Discussion started by: ashis.tewari
1 Replies

4. UNIX for Dummies Questions & Answers

User information script

Hi Guys, I just started learning unix and was wondering if anyone can assist me with my User info script.The script file lets the user input their personal information (Their name, address, phone number etc...). The script will then ask the user to input the info again if the input is incorrect... (2 Replies)
Discussion started by: rc1138
2 Replies

5. Linux

How to Burn .gp Oracle 9.2.0.4.0 to Compact Disc Media on Windows Box

Hi All, I Downloaded Oracle 9.2.0.4.0 for Linux AS 4 and the file format is Directions to extract the files 1. Run "gunzip <filename>" on all the files. Eg. ship_9204_linux_disk1.cpio.gz 2. Extract the cpio archives with the command "cpio -idmv < <filename>" Eg. cpio -idmv... (0 Replies)
Discussion started by: prakashpichika
0 Replies

6. Windows & DOS: Issues & Discussions

formatting a Compact Flash in DOS format

:confused: I tryied to use the mount Command (and the msdos.utils) in Darwin 1.4 (OS X) to format a Compact Flash in DOS Format (I had already this native format but I changed it with Disk Utility in MacOS standard and the PC Card slot of a Windows 98-Laptop can't nore read the card) I want to... (1 Reply)
Discussion started by: dreamsurfer
1 Replies
Login or Register to Ask a Question