INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

AWK Stops Processing a Data File Randomly

AWK Stops Processing a Data File Randomly

(OP)
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 normalized_14_1000.data 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 normalized_14_1000.data has almost 140.000 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.

RE: AWK Stops Processing a Data File Randomly

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
tgmlify - code syntax highlighting for your tek-tips posts

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close