General :: Looping Through Csv File To Calculate Avg/min/max?

Sep 1, 2010

I have a csv file (id, loc, timestamp, impressions) that I need to derive some low-level calculations from. Im ok with basic sort and grep operations, but this one is challenging my feeble scripting skills (normally I�d throw it into a spreadsheet, but in this case Id like to ultimately create a script that I could automate). Ive already used cat/sort to order the csv file first on location and then timestamp so it looks like this:

Abt001, AA, 2009-01-01 10:51:00, 231
Cup002, AA, 2009-01-01 10:54:00, 3
Saf001, AB, 2009-01-01 10:51:00, 25

[code]....

What Id like to do is output to file a record of the total, min, and max number of impressions for each location. , e.g.

AA6504 3231
AB252525
AC37925109
ZZ35512341

how to do this and Im kind of stuck on how to approach it I think the combined steps of looping through the locations along with the min/max/sum calculations are throwing me. Eventually Id also like to do additional calculations like average, ect. but I think I can figure that out on my own if I can just get this part down.

View 10 Replies


ADVERTISEMENT

General :: Mapping With Series From Master File And Calculate Count?

Sep 7, 2010

My shell script is calculating the count of each shortcode series wise whose sample output is as follows:

Code:

56882
9124 1
9172 1
9173 4

[code]....

View 1 Replies View Related

Programming :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 Replies View Related

General :: Change The Value Of The Inputs In Sed While Looping?

Feb 21, 2011

how to change the value of the inputs in sed while looping

As such:

for i in `seq 1 10`; do
"do something funny, using OpenFOAM"
cd system
sed 's/oldvalue/oldValue+increment/' -i sampleDict
cd ..
done

So basically, can you for instance create a constant "a" and increase it for every loop interval and use it for sed?

View 2 Replies View Related

General :: Looping Through A Shell Script With Sql Statements?

Oct 7, 2009

I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting; Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a jist of what I'm attempting, below.

1. Copy file to be processed (one file at a time, from a list of 10 files in the folder ).

Code:

for i in *
do
cp $i /home/temp

2 . Create a snapshot(n) table : Initialize n = 1

Code:

create table test insert account_no, balance from records_all; -- creates my snapshot table and inserts records in SQL

3. Checking if the table has been created successfully:

Code:

select count(*) from snapshot1 -- query out the number of records in the table -- always fixed, say at 400000

Code:

if( select count(*) from snapshot(n) = 400000 )
echo " table creation successful.. proceed to the next step "
else
echo " problem creating table, exiting the script .. "

4. If table creation is successful,

Code:

echo " select max(value) from results_all " -- printing the max value to console

[code]....

View 7 Replies View Related

Programming :: Calculate Flash Memory End Address Of A Certain File?

Mar 9, 2011

how to calculate (if possible) the end address of an image file in a flash memory. I'm trying to create a checksum and checkheader function and the info that I got is the file's offset, how many sector it consumes and its size. I kinda need the end address, sad thing is, I don't know how to calculate it.test.img's start address is 0, the size is 0x20000 and consumes 3 sectors.

View 6 Replies View Related

General :: How To Calculate Video Resolutions

Jun 2, 2011

I am familiar with common video resolutions like 320x240, 640x480 and 720x480. Sometimes I want to use other video resolutions when encoding videos. Is there a formula to calculate the unknown value for the heightxwidth if one value is supplied? For example, if I want my video to be 480xWidth, what value should Width be to get proper aspect.

View 2 Replies View Related

General :: Calculate Local Time In Seconds?

Sep 3, 2010

I`m looking to calculate my Local Time in seconds from APOC - 1970.I found only - date +%s -> that display the UTC and not my Local Time.

View 3 Replies View Related

General :: Calculate The Hours Usage Per Day Over A Certain Period?

Dec 13, 2010

Between the dates 21-June-2007 to 12-December-2010 there are 1270 days. If the total cumulative time a hard drive has been active is 344 days (found this via Disk Utility in Ubuntu 10.10) since it was bought 1270 days ago. What is the average usage hours per day?

View 2 Replies View Related

General :: Calculate Duration In Seconds In Bash ?

Nov 15, 2010

I would like to subtract the end time with a start time in bash. How can I do it?

Here's a script of example of what I want:

View 8 Replies View Related

General :: Calculate Time Period In Scripting

Mar 16, 2011

Now i am writting one bash script. in that my requirement is i need to create one directory and that the directory details to be stored in one file Ex. date/time and all in one file. after that i need to delete the folder automatically exactly after 3months. between these time period in 2month itself i need to send one mail to admin "regarding this still one month only more to delete the folder" . is it possible to do like that date calculation in script.

View 10 Replies View Related

General :: Calculate Total Memory Consumed By User?

Sep 20, 2010

is there a way to calculate the total memory consumed by user ?

View 12 Replies View Related

General :: Calculate Usable Bytes On A Disk Partition?

Mar 10, 2010

How do you calculate the number of usable bytes on a disk partition? When I do an fdisk -l I get this:

Disk /dev/md0: 192.0 GB, 192069500928 bytes
2 heads, 4 sectors/track, 46891968 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

[code]...

View 7 Replies View Related

Software :: Scp Is Looping Without Being In A Loop?

Jun 18, 2010

I'm trying to execute some fairly simple code to transfer some files from one server to another.

$ cat xfer_directory.sh
#!/bin/bash
cd /cygdrive/g/directory/usr

[code]....

View 1 Replies View Related

General :: Calculate Minimum Ext3 Partition Size For Certain Amount Of Data?

Aug 5, 2011

These following ext3 partitions contain identical data. As we can see, the larger the partition size, the more space is required for the same files:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop11 3965777 561064 3199964 15% [...]
/dev/loop19 573029 543843 29186 95% [...]

[code]....

View 2 Replies View Related

General :: Grep String From Logs Of Last 1 Hour On Files Of 2 Different Servers+calculate Count?

Sep 3, 2010

I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files. File structure is same on both servers and for reference as follows:

Code:

27-Aug-2010 10:04:30,601|919122874903|phtunes_app|1282243292627|NotifySmsReception|DMGenerateLogInterceptor - ExternalTransactionID:SDP-DM-26713018, TransactionStatus:Requested
27-Aug-2010

[code]....

View 6 Replies View Related

OpenSUSE Install :: Update Keeps Looping Back?

Apr 5, 2010

I've had openSUSE for a week. The update says that there are 10 updates. When I run it, first I get a flag saying that something can't be removed. Then when I run the rest of the up date, it loops back and starts over. I need a patch to fix the patch that fixes the patch that...etc.

View 8 Replies View Related

Ubuntu :: Computer Boot Looping Before Grub.

Mar 10, 2010

I have 9.10 installed, grub has loaded and worked, now all of a sudden nothing will boot.The HP screen comes up and then the computer reboot, constant reboot cycle. Can't even get into the BIOS. It will just sit there if I hit escape. Won't boot the live cd either. What can I do??? It has worked fine for the past month now.

View 6 Replies View Related

Ubuntu :: Bash Script Not Looping As Intended?

Nov 2, 2010

I've written a bash script to connect to each machine in our local network and update the fstab file to point certain NFS mounts to a new location.The script is meant to read in a list of shares and a list of workstations, rsync the relevant share then connect to each workstation and update the fstab file before moving onto the next share.In reality what is happening is it will perform the loop correctly for the first workstation in the list but will not move on to the next one. I'm really stumped on this and I'm sure it's something simple but I just can't seem to work out the answer!

Code:
#!/bin/bash
SHARES=$1

[code]....

View 6 Replies View Related

Ubuntu :: BASH Script Keeps Looping Infinitely?

May 27, 2011

I have a simple .bashrc backup script I've been working on, but my external hard drive needs to be plugged in for it to work. So I set up a while loop, that exits after the hard drive has been plugged in and backed up. Here it is:

Code:
#/bin/bash
pluggedin=1

[code]....

View 4 Replies View Related

Programming :: Looping Over Mysql Query Results In Bash?

Sep 15, 2010

I am querying a single string column in a table. The string values have spaces in them. I want to loop over each value in bash. I set IFS to split lists on newlines instead of spaces. When I try this, it is splitting the list of results on the actual character 'n', not the newline ''.

DATA=`mysql -u root -ppassword --silent 'SELECT name FROM table_a;'`
IFS=$'
'
for i in $DATA; do
echo "item = $i"

[Code]....

View 5 Replies View Related

Programming :: Looping Throghu Input Files With Different Number Of Days?

Nov 3, 2010

I want to itemize addition for each type of transactions. The example below is for 3 days,10/13/2010, 10/14/2010, & 10/15/2010.

PROD =89.25+89.25+104.47= 282.97
TAX =9.37+9.37+10.37 = 29.71
ETAX = 1+1+1 = 3

[code]...

View 8 Replies View Related

Ubuntu Installation :: Make Dell Spash Screen Stop Looping?

Oct 18, 2010

Why, after a successful (I thought) dual boot installation w/ a side-by-side lynx and meerkat install and XP does my system refuse to boot? It just gets to the Dell screen, giving boot options (none of which are making any difference) and keeps looping it. Last night, after re-installing the grub (lost after the XP install) everything was working fine. I powered down and this morning tried to restart and...this. I really don't want to have to reinstall everything and reconfigure and reinstall apps--what can I do? And more importantly, WTF did this happen to begin with?

View 1 Replies View Related

Programming :: VBA / Excel - Looping Through Image Controls Based On Cell Contents?

Jun 28, 2011

I have an Excel Spreadsheet which reports upon weekly performance. One portion of the worksheet looks at week over week increases /decreases. I've placed a number of image controls (15 in Total) next to cells which calculate week over week change. The image controls simply display an image depending on whether the value of the adjacent cell is positive or negative. So, here is my basic working IF statement:

Code:

Private Sub Worksheet_Change(ByVal UpDown As Range)
If Range("J26") > 0 And IsNumeric(Range("J26").Value) Then
Image1.Picture = LoadPicture("C:path oup_arrow.gif")
ElseIf Range("J26") < 0 And IsNumeric(Range("J26").Value) Then

[code]....

As you can see, this is pretty simple. What I'd like to do is find a way to loop through all 15 controls and avoid having 15 IF statements run on the Worksheet_Change() event. The cells containing the week over week values are all in the same column, but not continuous. Involved cells are: ("J26", "J27", "J33", "J34", "J35", "J36", "J37", "J38", "J39", "J40", "J42", "J43", "J44", "J45", "J46")

View 6 Replies View Related

General :: Calculate 3rd Column Which Should Be Addition Of Value In 1 And 2nd Column?

Jul 19, 2010

How would i calculate following values.Initial file

10 3
20 4
How would i calculate 3rd column which should be addition of value in 1 and 2nd column.File after calculation
10 3 13
20 4 24

View 14 Replies View Related

Ubuntu :: Could Not Calculate The Upgrade

May 29, 2010

I can't upgrade. I get:

Quote:

Could not calculate the upgrade

An unresolvable problem occurred while calculating the upgrade: The package 'skype-common' is marked for removal but it is in the removal blacklist.

This can be caused by:

* Upgrading to a pre-release version of Ubuntu

* Running the current pre-release version of Ubuntu

* Unofficial software packages not provided by Ubuntu

This is most likely a transient problem, please try again later.

I tried again several times in different days and it is the same. I have 10.4 recently updated from my original installation of 9.10. I think it was not a pre-release, I did it automatically from the website and it took a long time. As far as I know, all I have installed is official, except perhaps Skype itself. There seems to be something connected with Skype. But I have exactly the same Skype I had with 9.10, where I updated every few days with no trouble. It is something peculiar in 10.4

View 7 Replies View Related

Red Hat :: Calculate Bytes-per-inodes Value?

Feb 17, 2010

I am a brand new member

here is my question :

in a RedHat configuration :

i need to be sure that a partition has been formatted with those parameters code...

View 3 Replies View Related

Ubuntu Installation :: 9.10 > 10.04: Could Not Calculate The Upgrade

May 3, 2010

I tried to upgrade Ubuntu Server Edition 9.10 to 10.04. Gives me this warning:

Code:

Could not calculate the upgrade An unresolvable problem occurred while calculating the upgrade: E:Unable to correct problems, you have held broken packages.However, the packages appear to be fine. Checked with apt-get and nothing wrong.

View 9 Replies View Related

Ubuntu Installation :: Could Not Calculate The Upgrade To 8.10

Jul 19, 2010

i have problem with upgrade manager. i try upgrade fron 8.04 to 8.10. where is my main.log:

2010-07-19 15:52:51,749 INFO release-upgrader version '0.93.34' started
2010-07-19 15:52:51,752 DEBUG Using 'DistUpgradeViewText' view
2010-07-19 15:52:51,795 DEBUG enable dpkg --force-overwrite

[code]....

View 1 Replies View Related

Ubuntu Installation :: 11.04 - Could Not Calculate The Upgrade

May 30, 2011

I received the following error today and I did a search on the net. I tried sudo rm /var/cache/apt/archives/* but it didn't help. Could not calculate the upgrade An unresolvable problem occurred while calculating the upgrade. report this bug against the 'update-manager' package and include the following error message: 'E:Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.'

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved