Sponsored Content
Top Forums Shell Programming and Scripting multidimensional arrays using awk Post 302368411 by rdcwayx on Wednesday 4th of November 2009 08:44:06 PM
Old 11-04-2009
little issue in tomato.

Code:
$ awk -F, '{if ($1~/y/) {A[$2]++} else {B[$2]++} } END { for (i in B) print i, A[i],B[i]}' OFS="," urfile
tomato,,2
cheese,2,1
pizza,3,1

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multidimensional arrays

I have a file that's logically in the form of a multidimensional array with an unknown number of records in the file. The file looks like this: name1 data1 name2 data2 name3 data3 ... nameN dataN How do I load this file into an array for processing, while... (2 Replies)
Discussion started by: leslie02
2 Replies

2. Shell Programming and Scripting

Awk multidimensional Array

Hello Experts,, Can anybody give me a brief idea what is following bold letter statement is for!! what is the term called so that I can google for it.. It seems to be an array inside another array.. awk' /TXADDR/ { txaddr=$NF } ##understood /TXDATA/ { txdata]=$NF... (1 Reply)
Discussion started by: user_prady
1 Replies

3. Shell Programming and Scripting

awk multidimensional values

Hello All, Here is my input file content and i am trying to write an awk file that produces the output as shown below. i tried with my little knowledge but was not successful. Input File content: ID COL1 COL2 COL3 1002 1 val21 val31 1002 2 val22 val32 1002 3 val23 val33... (2 Replies)
Discussion started by: forumthreads
2 Replies

4. Shell Programming and Scripting

AWK multidimensional array

In a single dim. awk array, we can use : <index> in <array name> to determine whether a particualar index exists in the array or not. Is there a way to achieve this in a awk multi dim. array ? (4 Replies)
Discussion started by: sinpeak
4 Replies

5. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

6. Shell Programming and Scripting

multidimensional array in awk

Hi, I was trying to process a file with the help of awk. I want to first display all the rows that contains 01 and at the end of processing I have to print some portion of all the lines. like below. Output expected: (2 Replies)
Discussion started by: ahmedwaseem2000
2 Replies

7. Programming

Multidimensional arrays and sort.

My language is C++. I have a multidimensional vector that I would like to sort by a specific "cell" or "field" within the main vector. Does anyone have any information on how to do this? I have searched all over the internet and every reference manual I can find. So far I have found very little to... (2 Replies)
Discussion started by: sepoto
2 Replies

8. Shell Programming and Scripting

Multidimensional arrays

Hi Experts, I'm a newbie.....multidimensional arrays in shell scripts is possible??? If so, can anyone guide me with an example.....and also can anyone tell me, how we can create a table like ouput format in shell script....the output should look like this one: 1 2 3 4 5 6 6 5 4 3... (4 Replies)
Discussion started by: kritibalu
4 Replies

9. Shell Programming and Scripting

Multidimensional arrays Shell Programming and Scripting

I have two files: file-1 is a list of number of interfaces in the switch and file-2 have VLAN-ID , VLAN-NAME , Interface belong to that VLAN like this: file-1: 1/1 1/2 1/3 1/4 1/5 . . file-2: 1,"vlan-wifi",1/1,1/7,1/8 (9 Replies)
Discussion started by: SULTAN01
9 Replies

10. Shell Programming and Scripting

Multidimensional array:awk error

awk -F'\t' -v OFS='\t' ' { if($2 in arr) { #print "Sahi", NR,arr for(k=2;k<=NF;k++){ # sum]+=$2 } } else { arr=NR #print "awk",NR for (k=3;k<=NF ; k++){ sum=$k } } } (7 Replies)
Discussion started by: genome
7 Replies
Tangram::Type::Dump::Any(3pm)				User Contributed Perl Documentation			     Tangram::Type::Dump::Any(3pm)

NAME
Tangram::Type::Dump::Any - Intuitive DataBase InterFace SYNOPSIS
# ... in a nearby Tangram::Schema structure ... SomeClass => { fields => { idbif => { -options => { dumper => 'Data::Dumper', }, some_field => undef, some_property => undef, some_attribute => undef, each_one => undef, gets => undef, saved => undef, }, string => { cheese => undef, }, }, }; DESCRIPTION
The idbif mapping type collates multiple data members into a single perl_dump (see Tangram::Type::Dump::Perl), storable (see Tan- gram::Type::Dump::Storable) or yaml (see Tangram::Type::Dump::YAML) column. For instance, with the schema definition in the example, all the columns in the example would be serialised via Data::Dumper. If you stored an object like this: $cheese = bless { cheese => "gouda", gets => 6, each_one => 9 }, "SomeClass"; You would see something in your database similar to: /^'--v------v--------v----------------------------'^ | id | type | cheese | idbif | >----o------o--------o------------------------------< | 1 | 42 | gouda | { gets => 6, each_one => 9 } | \_,--^------^--------^----------------------------._/ (note: the actual output from your SQL Database client may differ from the above) So, if you're the sort of person who likes to set their attributes with accessors, but doesn't like the overhead this places on the RDBMS... then this may help. Note: the real benefits of this mapping type are for when you're storing more complex data structures than "6" and "9" :-). You may prefer to use the default dumping type, which is storable. LINKS TO OTHER OBJECTS If Tangram encounters another object which is already in storage (ie, has been inserted via "$storage->insert($foo)"), then it will store a "Memento". This memento includes the object ID, which is sensitive to schema changes (the ordering of classes in the schema). If the class implements a "px_freeze" and "px_thaw" function, then there will be a "Memento" that includes the class name of the object, and the data that was returned by the class' "px_freeze" method. To be reconstituted, it is called as: SomeClass->px_thaw(@data) See Tangram::Type::Dump for more details on the complicity API. Please set RETVAL to be the thawed object. (that is, return a single scalar). BUT, I REALLY, REALLY HATE SCHEMAS! However, maybe you are one of those folk who don't like to declare their attributes, instead peppering hashes willy nilly, then there is another option. Instead of explicitly listing the fields you want, if you don't specify any fields at all, then it means save ALL remaining fields into the column. For convenience, "-poof" is provided as a synonym for "-options", so you can write: { fields => { idbif => { -poof => # There goes another one! { }, } }, } [ You see, Tangram::Type::Dump::Any isn't actually an intuitive DB interface. No, an intuitive DB interface is a user interface component, and that title is reserved for Visual Tangram. VT expects to pick up the title with any luck by the end of the 21st century^W RSN! I Don't Believe In Fairies is actually what it stands for. It's a completely arbitrary name; chosen for no reason at all, and certainly not anything to do with Pixie. ] perl v5.8.8 2006-03-29 Tangram::Type::Dump::Any(3pm)
All times are GMT -4. The time now is 09:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy