Sponsored Content
Top Forums Shell Programming and Scripting How to load different type of data in a file to two arrays Post 302244854 by ahjiefreak on Wednesday 8th of October 2008 09:18:00 PM
Old 10-08-2008
How to load different type of data in a file to two arrays

Hi,

I have tried to find some sort of previous similar thread on this but not quite close to what I want to achieve.

Basically I have two class of data in my file..e.g
1,1,1,1,1,2,yes
1,2,3,4,5,5,yes
2,3,4,5,5,5,no
1,2,3,4,4,2,no
1,1,3,4,5,2,no

I wanted to read the "yes" entry to an array and "no" entry into another array.

From there, I wanted to do a random selection of yes[1] or yes[2] to duplicate the existing records.The same goes for no[1],no[2] and no[3].

Could anyone shed some light on this?

I tried some partial solution below but it doesnt work:-


Code:
#!/bin/bash

awk -F, ' {


if($NF=="yes"){
  i++;
  yes[i]=$1;
}

else if($NF=="no"){
       j++;
          no[j]=$1;
}


}' myfile

I tried to do echo ${yes[@]} and echo ${no[@]} but it doesnt print anything.


Please advise. Thanks.
 

10 More Discussions You Might Find Interesting

1. Programming

FILE data type

Hi all, Can anyone tell me a little about the datatype FILE, which represents stream. What does its structure look like, and in which header file is it defined and so on... Ex : FILE *fp ; fp = fopen("filename", "w") ; (6 Replies)
Discussion started by: milhan
6 Replies

2. Shell Programming and Scripting

Reading in data sets into arrays from an input file.

Hye all, I would like some help with reading in a file in which the data is seperated by commas. for instance: input.dat: 1,2,34,/test for the above case, the fn. will store the values into an array -> data as follows: data = 1 data = 2 data = 34 data = /test I am trying to write... (5 Replies)
Discussion started by: sidamin810
5 Replies

3. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

4. Shell Programming and Scripting

Need help in wrting Load Script for a Load-Resume type of load.

hi all need your help. I am wrting a script that will load data into the table. then on another load will append the data into the existing table. Regards Ankit (1 Reply)
Discussion started by: ankitgupta
1 Replies

5. Shell Programming and Scripting

how to check the file data type(ascii or binary)

hi i am receiving a file from one system , i have to verify the format of the file data i.e whether the data is in acii format or binary format, please help thanks in advance satya (1 Reply)
Discussion started by: Satyak
1 Replies

6. Shell Programming and Scripting

load a data from text file into a oracle table

Hi all, I have a data like, 0,R001,2,D this wants to be loaded into a oracle database table. Pl let me know how this has to be done. Thanks in advance (2 Replies)
Discussion started by: raji35
2 Replies

7. Shell Programming and Scripting

Load data to flat file from table.

Hi all, I need to know how to copy data from a table say ABC to a flat file say XYZ.dat in unix, Please leave ur comments and the fastest way to do so, I need to load the table records into flat file. Regards Ann (4 Replies)
Discussion started by: Haque123
4 Replies

8. Web Development

script to load data from csv file

hello i want a script to load the data line by line from a csv file into a mysql table (3 Replies)
Discussion started by: srpa01red
3 Replies

9. UNIX for Dummies Questions & Answers

Verify the data type in a file with UNIX function

I am seeking help on this UNIX function, please help. Thanks in advance. I have a large file, named as 'MyFile'. It was tab-delmited, I am told that each record in column 1 is unique. How would I verify this with UNIX function or command? (1 Reply)
Discussion started by: duke0001
1 Replies

10. Shell Programming and Scripting

Load data from a flat file to oracle.

I have a flat file with records like Header 123 James Williams Finance2000 124 Pete Pete HR 1500 125 PatrickHeather Engg 3000 Footer The structure is: Eno:4 characters Name:8 characters Surname : 9 characters Dept:7 characters Sal:4characters These are sample... (1 Reply)
Discussion started by: Shivdatta
1 Replies
GO::Model::Evidence(3pm)				User Contributed Perl Documentation				  GO::Model::Evidence(3pm)

NAME
GO::Model::Evidence - evidence for an association SYNOPSIS
my $ev_l = $association->evidence_list; foreach my $ev (@$ev_l) { print "Evidence for association %s : %s ", $association->gene_product->symbol, $ev->code; } DESCRIPTION
evidence for an association see http://www.geneontology.org/GO.evidence.html for a list of evidence codes code Usage - $ev->code("IEA"); Returns - Args - gets/sets the evidence code see http://www.geneontology.org/GO.evidence.html seq_acc Usage - Returns - Args - gets/sets the sequence accesion GO::Model::Xref ALPHA CODE - API may change used to set the GO::Model::Xref list from a text string. eg $ev->seq_acc("SGD:RRP41; SGDID:L0003550"); will actually add two GO::Model::Xref objects This method doesnt really belong in the GO::Model::* hierarchy as it contains parsing code. Its a minor hack mainly due to the fact that this data is still denormalized in the database. add_seq_xref Usage - Returns - Args - equivalent to WITH column in gene_association files, and evidence_dbxref tables in db add_pub_xref Usage - Returns - Args - xref Usage - Returns - Args - gets/sets the literature or sequence reference GO::Model::Xref NOTE: at some point we may want to deprecate this method and persuade API client code to call $ev->literature_xref instead, to make explicit the fact that this is a literature reference as opposed to a sequence reference xref_list Usage - Returns - GO::Model::Xref listref Args - returns all (sequence and literature) references xref Usage - Returns - Args - deprected - sets first pub_xref_list valid_codes Usage - print join("; ", GO::Model::Evidence->valid_codes); Returns - string array Args - list of valid evidence codes perl v5.14.2 2013-02-07 GO::Model::Evidence(3pm)
All times are GMT -4. The time now is 07:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy