Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK Stops Processing a Data File Randomly

Status
Not open for further replies.

mhasanbulli

Instructor
Aug 7, 2012
1
NZ
Hi,

I am having some problems with a single line of awk code. I have .data files and I am trying to manipulate data in one file and write it into other file. This code works in most of the .data files I have. However, it suddenly decides to stop working on some files. The line of code I am using is

Code:
awk -v t=14 -v s=1000 '{printf "%.20f\n", ($2*$2)*((1/($1**2))+(s/(t**s))*($1**(s-1)))*0.0001;}' normalized_14_1000.data > out.data

When I process [tt]normalized_14_1000.data[/tt] it start doing the calculation but suddenly stops doing what it is supposed to do and produces the following

Code:
.
.
.
0.00009742961186584262
0.00009741012836261867
0.00009739064875556540
0.00009737117304390360
-nan
-nan
-nan
-nan
.
.
.

File [tt]normalized_14_1000.data[/tt] has almost [tt]140.000[/tt] lines of data. There are no values that might cause zero-divisions. I thought maybe something is wrong with the .data file but I re-generated the file. But, I get the same thing at the same position. It is just a weird behavior. I was wondering if there is a solution to this, or, any suggestions that might cause this behavior.

Thank you very much in advance.

Mus.
 
It would help if you showed us the lines of source data where the problem occurs.

Have you tried just chopping a few lines out of the source data (i.e. some good ones and the ones that cause the problem) and processing them separately? Does the problem still occur in that case?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top