Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: delete colu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 34 of 36 Topic 2215 of 2236
Post > Topic >>

Re: delete columns csv file

by Janis Papanagnou <Janis_Papanagnou@[EMAIL PROTECTED] > Apr 17, 2008 at 01:55 AM

r wrote:
> On Apr 16, 4:16 pm, Janis <janis_papanag...@[EMAIL PROTECTED]
> wrote:
> 
>>>Returning to my example: sorry to re-start with this issue of reading
>>>the file twice, would you direct me towards the section of the gawk
>>>guide that explains what you call a "2-pass solution". I'd like to
>>>learn the gawk technical phrase for this task and read the background.
>>
>>That has nothing to do with gawk. Many tools operate on data streams
>>sequentially but have tasks to do that can only be completed if the
>>data is already fully known to them; so you read the same file twice.
>>In awk that can be done by providing the filename two times in the
>>argument list.
>>
>>  awk -f awkprog  datafile  datafile
> 
> 
> Thanks; the only analogy I can think of is when I create my dvi file
> from activating my latex command twice. Interesting to know of this
> requirement to read a file twice.

It's a natural requirement for any program that does no implicit
rewrites/resets or random access (seeks) on a file. Basically,
awk is a filter program that reads streams of data sequentially.

> 
> 
>>
>>>Similarly, I've understood the terms NR and FNR but could not find
>>>reference to the equation NR==FNR, which section of the gawk guide
>>
>>It's just the equality operator as known from mathematics.
>>
>>Since you know what each variable means you just have to think about
>>the values they will take while awk is processing the first file and
>>while processing the second file.
>>
>>
>>>should I read to learn that it is possible to conceive this equation?
>>>As a complete novice, where do I learn that after learning the
>>>definition of NR and FNR independently, it is possible to use these
>>>functions with ==?
>>
>>You can compare values of the same type most generally.
>>(Sometimes awk performs implicit conversions before comparison.)
>>
> 
> Is there a definitive list of types of values where awk makes implicit
> conversions, or is this of relative minor importance to me?

It is of minor importance to you at your current level of knowledge
about awk, I suppose. But it's basic knowledge, anyway. The list is:
numbers and text strings. (If you're interested have also a look at
explicit conversions from numbers to strings and vice versa; str+0,
num"".)

> 
> 
> 
>>>The gawk guide introduces the term 'i++' in section 1.3 but '++' is
>>>explained (correctly?) as increment operator in section 5.8? Why is
>>>increment necessary in this example?
>>
>>The ++ is the increment operator. You need a variable to increment.
>>Here i is the name of the variable to increment.
>>
>>(To explain the necessity in "the" example I'd need the context.)
>>
> 
> The example I cite is in my first message that created this topic of
> discussion.

It's good style (and a sign of respect for the people trying to help
you) to quote enough context to make any posting self-contained.

> 
>>>So far, apart from my failure to understand NR==FNR, I understand as
>>
>>NR==FNR is true while you're processing the first file of the
>>argument list. If the same filename is given twice then you can
>>call that condition "first pass" on the file.
>>
> 
> 
>>All that are really the basic basics of the awk language;
>>I'd suggest to read some more of the GNU awk guidebook.
> 
> 
> I'm on to it when time permits! :)

Good luck.

Janis




 36 Posts in Topic:
delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-03 12:19:05 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-03 14:51:04 
Re: delete columns csv file
Hermann Peifer <peifer  2008-04-03 22:27:16 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-03 15:42:10 
Re: delete columns csv file
Hermann Peifer <peifer  2008-04-04 07:32:38 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 09:23:00 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-04 08:04:52 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-03 14:00:32 
Re: delete columns csv file
Cesar Rabak <csrabak@[  2008-04-03 20:58:21 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-03 14:04:21 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-03 18:27:55 
Re: delete columns csv file
pop <p_o_p@[EMAIL PROT  2008-04-03 20:45:14 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-03 20:46:10 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-03 19:38:05 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-03 22:19:49 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-04 08:38:19 
Re: delete columns csv file
Janis <janis_papanagno  2008-04-04 01:31:18 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 11:19:03 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-04 08:20:19 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 15:51:14 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-04 08:53:58 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 18:31:55 
Re: delete columns csv file
Janis <janis_papanagno  2008-04-04 05:19:46 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 15:37:07 
Re: delete columns csv file
Hermann Peifer <peifer  2008-04-04 07:28:48 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-04 09:41:43 
Re: delete columns csv file
pk <pk@[EMAIL PROTECTE  2008-04-04 18:33:03 
Re: delete columns csv file
Hermann Peifer <peifer  2008-04-04 19:13:07 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-16 07:08:05 
Re: delete columns csv file
Ed Morton <morton@[EMA  2008-04-16 23:35:25 
Re: delete columns csv file
Janis <janis_papanagno  2008-04-16 08:16:29 
Re: delete columns csv file
gazelle@[EMAIL PROTECTED]  2008-04-16 15:33:42 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-16 14:58:52 
Re: delete columns csv file
Janis Papanagnou <Jani  2008-04-17 01:55:39 
Re: delete columns csv file
r <inpost@[EMAIL PROTE  2008-04-17 16:01:03 
Re: delete columns csv file
Janis Papanagnou <Jani  2008-04-18 01:54:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 5:39:14 CDT 2008.