From: rbalasus on
On 4 Mrz., 06:23, Ed Morton <mortons...(a)gmail.com> wrote:
> On 3/3/2010 12:18 PM, rbala...(a)gmail.com wrote:
>
>
>
>
>
> > Calculations in .csv via SED AWK
>
> > Hello is there a way to make easy calculations in .csv files through
> > sed awk?
>
> > In my case I want to do the following:
> > date;cat;amount
> > 01.01.2010;CAT1;60
> > 01.01.2010;CAT1;5
> > 01.01.2010;CAT2;7
> > 01.01.2010;CAT2;50
> > 01.02.2010;CAT2;1
> > 01.02.2010;CAT2;2
>
> > I need a summarization and grouping by month.
>
> > month;cat;sumamount
> > 01;CAT1;65
> > 01;CAT2;57
> > 01;CAT2;3
>
> ITYM:
>
>     02;CAT2;3
>
>
>
> > maybe there is a way to process this step by step in a loop, but for
> > me is interesting if there is a way to use some basic lowlevel tools
> > for this task.
>
> > Regards Randolf Balasus
>
> $ cat file
> date;cat;amount
> 01.01.2010;CAT1;60
> 01.01.2010;CAT1;5
> 01.01.2010;CAT2;7
> 01.01.2010;CAT2;50
> 01.02.2010;CAT2;1
> 01.02.2010;CAT2;2
>
> $ awk -F'[.;]' 'NR==1{print "month;cat;sumamount"; next}
> {s[$2";"$4]+=$5} END{for (i in s) print i";"s[i]}' file
> month;cat;sumamount
> 01;CAT1;65
> 01;CAT2;57
> 02;CAT2;3
>
> Regards,
>
>      Ed.

Thanks for your answer. As I saw, there was a typo in my description,
and you have found it. Your solution is exactly what I was eraching
for. Now I have only to understand how it is working....
Greetings Randolf Balasus
From: Kenny McCormack on
In article <583daaaa-ea13-40a3-b637-86765e2e12d8(a)r27g2000yqn.googlegroups.com>,
rbalasus(a)gmail.com <rbalasus(a)gmail.com> wrote:
>
>> What is "sed awk"? �Is that some new thing from GNU?
>No I was talking about the tool "sed" and about the other tool "awk"

So, if I start talking about the term "giraffe tuba", you will
understand that I am talking about this new musical instrument that has
a very long neck?

>both are part of the coreutils in most installations.

Not true. There are many computers in the word that don't run Linux.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

From: Stephane CHAZELAS on
2010-03-16, 07:33(-07), rbalasus(a)gmail.com:
>
>> What is "sed awk"?  Is that some new thing from GNU?
> No I was talking about the tool "sed" and about the other tool "awk"
> both are part of the coreutils in most installations.

No, neither sed nor awk are part of the GNU coreutils
(http://www.gnu.org/software/coreutils/), GNU sed and GNU awk
are separate projects from each other and from the GNU
coreutils.

--
Stéphane
From: Kenny McCormack on
In article <slrnhpv7ft.8vu.stephane.chazelas(a)spam.is.invalid>,
Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote:
>2010-03-16, 07:33(-07), rbalasus(a)gmail.com:
>>
>>> What is "sed awk"?  Is that some new thing from GNU?
>> No I was talking about the tool "sed" and about the other tool "awk"
>> both are part of the coreutils in most installations.
>
>No, neither sed nor awk are part of the GNU coreutils
>(http://www.gnu.org/software/coreutils/), GNU sed and GNU awk
>are separate projects from each other and from the GNU
>coreutils.
>
>--
>Stéphane

You don't expect anyone who refers to a tool as "sed awk" to get the
particulars about Linux/GNU distributions right.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

From: Sidney Lambe on
On comp.unix.shell, Kenny McCormack <gazelle(a)shell.xmission.com> wrote:
> In article <slrnhpv7ft.8vu.stephane.chazelas(a)spam.is.invalid>,
> Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote:
>>2010-03-16, 07:33(-07), rbalasus(a)gmail.com:
>>>
>>>> What is "sed awk"?  Is that some new thing from GNU?
>>> No I was talking about the tool "sed" and about the other tool "awk"
>>> both are part of the coreutils in most installations.
>>
>>No, neither sed nor awk are part of the GNU coreutils
>>(http://www.gnu.org/software/coreutils/), GNU sed and GNU awk
>>are separate projects from each other and from the GNU
>>coreutils.
>>
>>--
>>Stéphane
>
> You don't expect anyone who refers to a tool as "sed awk" to get the
> particulars about Linux/GNU distributions right.

And I don't expect an ignorant jerk who harasses someone over
the fact that they didn't write a Usenet subject line as
a grammatically correct sentence to ever have anything worthwhile
to say.

Very few of them are, Einstein. Subjects are not supposed to be,
or expected to be, grammatically correct sentences in any medium.

His meaning is very clear to everyone else here. And would be
to anyone else reading it.

<plonk>

I think this makes about 2 dozen of your sockpuppets I've killfiled.

Sid