Getting Array value based on another value

Hi
Im pretty new to Powershell, havnt tried to code in almost 15 years so Im a Little rusty to say the least. Im trying to make a script where I import a csv file into an array and then use foreach on one value to output another value. An example of the csv
file could be the following.
Client,Email,EmailAddresse
Company1,No,[email protected]
Company2,Yes,[email protected]
Company3,Yes,[email protected]
I have tried the code below to import the csv file into an array and then output the email address where email was set to "Yes"
$clientlist = Import-Csv E:\Script\Clients.csv
foreach ($client in $clientlist | where {$_.Email -eq "Yes"})
     Write-host $clientlist.emailaddresse
 When I execute the code I get the following output:
[email protected] [email protected] [email protected]
[email protected] [email protected] [email protected]
What I would like to get is just the one email address in each line, matching the email address from the csv where the value "email" was set to "Yes". What am I doing wrong?
Thank in advance
Anders Lausen

You could just filter using Where-Object without the need for the ForEach.
Import-Csv E:\Script\Clients.csv | Where {
$_.Email -eq 'Yes'
} | Select EmailAddress
Boe Prox
Blog |
Twitter
PoshWSUS |
PoshPAIG | PoshChat |
PoshEventUI
PowerShell Deep Dives Book

Similar Messages

  • How to get Array values from context

    In my jsp page, I have a group of checkboxes, named "checkbox" and each of them has a different value.
    <form>
    <input type=checkbox name=checkbox value=1>
    <input type=checkbox name=checkbox value=2>
    After I submit the form, I need to get the checkbox's values from next page's control file, which is a Java file. In the Java file, I use "com.sap.mbs.core.api.Context" class,
    String cbString = (String)context.getNodeList().get("checkbox");
    but I can only get the value of the first checkbox.
    I have tried context.getValue("checkbox", 0), context.getValue("checkbox", 1), context.getValue("checkbox", 2), but all I got is "null".
    I beleive the context has the value of the checkbox array. But how to get them out? Thanks a lot!

    Jo:
    You can download MAM application here
    ftp://148.87.8.191/server/outgoing/annie/MAM30.war
    Source code is in MAM30.src.zip.
    Also here is my view file, which may provide some clue:
    <?xml version="1.0" encoding="UTF-8"?>
    <view screen="/zjsp/zpm_enh_quickPassConf/zQuickPassConf.jsp" controller="ca.cn.sap.mobile.tis.pmenhQuickPassConf.controls.QuickPassConfManagement">
        <event name="onLoad">
           <forward name="error" component="error" view="ErrorDetail"/>
           <forward name="callback" component="zpm_enh_649" view="zPmEnh649Main" />
        </event>
        <event name="onGoEnh649">
         <forward name="default" component="zpm_enh_649" view="zPmEnh649Main" />
        <forward name="callback" component="zpm_enh_650" view="zPmEnh650Main"/>
       </event>
        <event name="onGoProcessRec">
         <forward name="default" component="zpm_enh_649" view="zPmEnh649Main" />
        <forward name="callback" component="zpm_enh_650" view="zPmEnh650Main"/>
       </event>
    </view>
    Thanks,
    Annie

  • How to get array values from one class to another

    Supposing i have:
    - a class for the main()
    - another for the superclass
    And i want to create a subclass that does some function on an array object of the the superclass, how can i do so from this new subclass while keeping the original element values?
    Note: The values in the array are randomly generated integers, and it is this which is causing my mind in failing to comprehend a solution.
    Any ideas?

    If the array is declared as protected or public in the superclass you can directly access it using its identifier. If not, maybe the superclass can expose the array via some getter method.
    If this functionality can be generified (or is generic enough) to apply to all subclasses of the superclass the method should be moved to the superclass to avoid having to reproduce it in all the subclasses.

  • Get array values from multidim array

    Hello Everyone,
    I am working with a two dim array. double twoDim[] = new double[100][100]. If I want to take "strips" of the array based on the x values I just do this.
    for(int i = 0; i < twoDim.length; i++)
         double a[] = twoDim;
    My question is how do I do a loop that returns a single dimensional array with respect to the y value ?  In effect doing this, (which fails miserably by the way).for(int i = 0; i < twoDim.length; i++)
    double a[] = twoDim[][i];
    Sincerely,
      Chem_E                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    That can't be done. The reason why it works so well with getting separate rows out of the 2d-array is that multi-dimensional arrays in Java are really just arrays of arrays.
    So each row is a separate array, which you can easily handle as a separate Object.
    You could wrap your 2d-array in a custom class (let's call it Matrix) and provide accessors that return views on the rows/columns (you could call them Vectors).

  • Help with getting array values from a file

    Hey ppl. Im doing a programming assignment just now and im completely stumped. I know i can ask my tutor but that will take a week (he is never in) so i was wondering if any of you could help. The basic idea is that you have to store numbers read from a file into an array. The catch is that you are not given the size of the array, you have to discover this by counting the numbers in the file. It terminates when -1 is discovered. This 'count' then states the size of the array.
    I got this done ok and i thought I was on easy street after that. All i had to do was read the numbers into the array but alas its not working. The compiler gives it the ok, but when i run the program i get the following error
    Exception in thread "main" java.lang.nullPointerException
    at marks.main(marks.java:48)
    By the way line 48 is as follows
    numbers[index] = Integer.parseInt(infile.readLine().trim());
    and here is the evil program!!!!!
    //Paul Rodger ***MARKS*** 14/1/02
    //A program which takes numbers from a file and enters them into an array.
    //The stream of numbers is terminated when the number -1 is discovered
    import java.io.*;
    class marks
    static BufferedReader keyboard = new
    BufferedReader(new InputStreamReader(System.in));
    static PrintWriter screen = new PrintWriter(System.out, true);
    static public void main(String[] args) throws IOException{
    FileReader file = new FileReader("numbers.txt");
    BufferedReader infile = new BufferedReader(file);
    //local Data
    int COUNT;
    double x;
    char ans;
    COUNT=0; // initialising the counter
    //inputs values and calculates the sum
    x = Double.parseDouble(infile.readLine().trim());
    while (x>=0){
    COUNT++;
    x= Double.parseDouble(infile.readLine().trim());
    // display the count
    screen.println("the number of values entered was : " +COUNT );
    // stores numbers in the array
    int[] numbers = new int[COUNT];
    for(int index=0 ; index < COUNT; index++)
    numbers[index] = Integer.parseInt(infile.readLine().trim());
    infile.close();
    Any help is appreciated!

    What was suggested is this -
    prior to this line ...
    int[] numbers = new int[COUNT];insert these lines ...
    file = new FileReader("numbers.txt");
    infile = new BufferedReader(file);An alternative solution, one which reads the file only once, is to do it this way ...
    1. read the numbers and put them into a List (either ArrayList or Vector)
    2. instantiate the array based on the size of List (list.size())
    3. populate the array from the list

  • Variable type Hierarchy, how to get the value from another similar variable

    Hi.
    We have created a variable, type hierarchy (using ORGEH hierarchy in HR based on 0ORGUNIT). Let's call this VAR1. We want to fill this with an User Exit, beacuse we want VAR1 to have the value from another variable, VAR2, which is also type hierarchy (and based on the same characteristic).
    However, when we program this user exit and use the VAR1 afterwards, it just behaves as if we have a single characteristic value and not a node value. As a result, we just get posts which do have the 'parent itself' as characteristic value, and none of the subnodes...  Any hints as to what we can do in our User exit to get the value passed over from VAR2 to VAR1 as a node value? Is there any spesific syntax to be used here that we are missing? ( The VAR1 and VAR2 are both defined as hierarchy variables, we have double checked...).

    Hi,
    are you on BI7.0? There you can create variables type replacement path and get the value out from a different variable without any coding.
    regards
    Cornelia

  • Change field value in a table, based on another field value in the same row (for each added row)

    Please Help, I want to change field value in a table, based on another field value in the same row (for each added row)
    I am using this code :
    <HTML>
    <HEAD>
    <SCRIPT>
    function addRow(tableID) {
    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);
    var colCount = table.rows[0].cells.length;
    for(var i=0; i<colCount; i++ ) {
    var newcell = row.insertCell(i);
    newcell.innerHTML = table.rows[1].cells[i].innerHTML;
    switch(newcell.childNodes[0].type) {
    case "text":
    newcell.childNodes[0].value = "";
    break;
    case "checkbox":
    newcell.childNodes[0].checked = false;
    break;
    case "select-one":
    newcell.childNodes[0].selectedIndex = 0;
    break;}}}
    function deleteRow(tableID) {
    try {var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    for(var i=0; i<rowCount; i++) {
    var row = table.rows[i];
    var chkbox = row.cells[0].childNodes[0];
    if(null != chkbox && true == chkbox.checked) {
    if(rowCount <= 2) {
    alert("Cannot delete all the rows.");
    break;}
    table.deleteRow(i);
    rowCount--;
    i--;}}}catch(e) {alert(e);}}
    </SCRIPT>
    </HEAD>
    <BODY>
    <INPUT type="button" value="Add Row" onClick="addRow('dataTable')" />
    <INPUT type="button" value="Delete Row" onClick="deleteRow('dataTable')" />
    <TABLE id="dataTable" width="350px" border="1">
    <TR>
    <TD width="32"></TD>
    <TD width="119" align="center"><strong>Activity</strong></TD>
    <TD width="177" align="center"><strong>Cost</strong></TD>
    </TR>
    <TR>
    <TD><INPUT type="checkbox" name="chk"/></TD>
    <TD>
    <select name="s1" id="s1">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    </TD>
    <TD><input type="text" name="txt1" id="txt1"></TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>

    Hi,
    Let me make sure u r working with table control.
    First u have to create a event(VALIDATE) to do the validation.
    Inside the event,
    1. First get the current index where user has pointed the curson
    2. Once u get the index read the internal table with index value.
    3. Now u can compare the col1 and col2 values and populate the error message.
    1. DATA : lo_elt TYPE REF TO if_wd_context_element,
                   l_index type i.
    lo_elt = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).
         CALL METHOD LO_ELT->GET_INDEX( RECEIVING  MY_INDEX = l_index.
    above code should be written inside the event.
    Thanks,

  • How to use SQL import to set the attribute value based on another?

    Hello all,
    I want to set an attribute of a dimension based on another attribute (if matches). Let's say I have a dimension PRODUCT. And I have defined two user defined attributes MANAGER and ISVISIBLE.
    Now within a PERMIT_READ program I want to set the ISIVISIBLE to true where the MANAGER Value is selected from a table.
    Something like
    <define a cursor c1 to select all the Manager values>
    sql import c1 into -
    :MATCHSKIPERR PRODUCT_MANAGER then <PRODUCT_ISVISIBLE (PRODUCT MANAGER) = true>
    <etc>
    Obviously the above is not correct. But I am stuck as to how this can be done? Can some one on this forum please help me with correct syntax/ approach please?
    Thanks a lot.
    Pxsheth
    This statement assigns true to the isvisible attribute for every gc_dim_bu dimension (selected as part of cursor c1).
    SO FAR SO GOOD.. NOW -
    If I want to change the above so that the attribute value gets assigned based on another attribute for the dimension (say a flag). i.e.
    Set the isvisible to true where attribute flag has a certain value. How do I code this in OLAP DML?

    There are a number of ways to do this. If you want to use an attribute that has been defined within AWM as an attribute of Product then simply using the mapping tool to populate the attribute as part of the normal dimension load procedure.
    Alternatively you could create an attribute at the DML level, and assuming you are not using surrogate keys, you can then define a cursor to read the relational table to populate your attribute. Something like this:
    sql declare MKT_BASKET cursor for -
    select PRODUCT_ID, PROD_MGR , PROD_VISIBLE -
    from PRODUCT_DIM
    if SQLCODE ne 0
    then goto ERROR
    sql open MY_CURSOR
    sql fetch MY-CURSOR loop into :append PRODUCT, :PRODUCT_MANAGER, :PRODUCT_ISVISIBLE
    sql close MY_CURSOR
    sql cleanup
    update
    commit
    If you want to create a complex PERMIT function using OLAP DML then personally I would create a formula and assign a program of type BOOLEAN and have the program return a YES or NO depending on the outcome of your test. Then your PERMIT_READ still references a dimension object. For example:
    DEFINE PROD.ISVISIBLE BOOLEAN FORMULA <PRODUCT>
    EQ PRG.ISVISIBLE(PRODUCT)
    DEFINE PRG.ISVISBLE PROGRAM BOOLEAN
    The program will then return Yes or No depending on the processing you need to do.
    Hope this helps
    Keith Laker
    Data Warehouse Solution Architect
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • URGENT:Making a poplist value freezed based on another poplist value

    Hi,
    I have a requirement to make a poplist value freezed(should get disabled so that no further change can be done) based on another poplist value.
    for ex : poplist 1 : A,B.
    poplist2: yes,no
    if A is selected, yes,no should appear in the poplist2.
    if B is selected, only YEs should appear in the poplist2 and it should get greyed out(disabled for further changing).
    Please help.
    Thanks,
    Veena.
    Edited by: Veena. on Dec 31, 2012 4:00 AM

    Veena,
    there is nothing urgent on this forum!
    You know that you should provide your jdev version so that we can help you solve your problem.
    Next it would help if you provide the code (of the page) so that we see how you setup the 'poplist' (whatever that exactly is).
    If you mean a selectOnceChioce you can implement a valuechangeListener on poplist A and depending on the new value set the value of poplist B to yes and disable it.
    Timo

  • How to get the values of an Array using JSP Tags

    Hey guys,
    I need some help. I've splited a String using
    fn:split(String, delim) where String = "1,2,3,4" and delim is ,
    This method returns an Array of splited Strings. how do i get the values from this array using jsp tags. I don't wanna put java code to achive that.
    Any help would be highly appreciated
    Thanks

    The JSTL forEach tag.
    In fact if all you want to do is iterate over the comma separated list, the forEach tag supports that without having to use the split function.
    <c:set var="list" value="1,2,3,4"/>
    <c:forEach var="num" items="${list}">
      <c:out value="${num}"/>
    </c:forEach>The c:forTokens method will let you do this with delimiters other than a comma, but the forEach tag works well just with the comma-delimited string.

  • Get numerical values from 2D array of string

    Hello! 
    I start by saying that I have a base knowledge of LabView. I'm using LabView 2011. I'm doing some communications test via Can-Bus protocol. As you can see in pictures of the block diagram and of the front panel that I've attached I'm using "Transmit Receive same Port" LabView example. It works very good but I would need to insert the 8 data bytes that I receive from the server in 8 different numerical variables so that I could use them to make some operations. How can I get numerical values from the 2D array of string that I attached? 
    Every example that you can provide is important! 
    Thank you very much! 
    Attachments:
    1.jpg ‏69 KB
    2.jpg ‏149 KB

    Hi martiflix,
    ehm: to unbundle data from a cluster I would use the function Unbundle(ByName)…
    When you are new to LabVIEW you should take all the FREE online resources offered by NI on their website!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to get a value from one item into another

    How can i get value from one item into another item.
    Ex: I have a report, in there i have check boxes, and when i have checked some rows, and press submitt, a prosses computates it into a item on another page, and a branche redirects to page 3. Then i'm going to use the value in the item into a PL/SQL script in an report to show the submittet items.
    How can i do this?
    Computation script, pages and all that is fixed. But i dont know which PL/SQL statement to use to get th value from the item.

    Hi Fredr1k,
    Use the V() function from pl/sql.
    e.g. V('P3_MY_ITEM')
    will return the value of that page item.
    As long as the pl/sql is called from within the Apex environment.
    Regards
    Michael

  • Get the values of hashmap in another class

    Hi All,
    i already posted this topic yesterday..But i did not get any helpful response..Kindly help me because I am new to java and I need some help regarding hashmap..
    I have a one value object java class which name is HashTestingVO.java
    *******************************************INPUT OF HashTestingVO.java***************************************
    public class HashTestingVO extends PersistentVO implements ILegalWorkFlowACLVO {
    public final static HashMap legalReviewPieceRelatedACLMap = new HashMap();
    legalReviewPieceRelatedACLMap.put("Futhure Path Check","ereview_acl_piece_related_cat1");
    legalReviewPieceRelatedACLMap.put("Send to Legal Review","ereview_acl_piece_related_cat1");
    legalReviewPieceRelatedACLMap.put("Review Precondition","ereview_acl_piece_related_cat1");
    Now i want to get the Hash Map values of this in another class called Testing.java class
    Ex: i need the value like this in Testing.java
    HashTestingVO obj=new HashTestingVO();
    obj.get(Futhure Path Check) -----------> I want to get the value of key1
    Public means you can access it another class..
    But Static means within the class we will use it...

    already posted this topic yesterday..But i did not get any helpful response..Kindly help me because I am new to java and I need some help regarding hashmap..I thing Exposing your dataStructure to any other class is not the right practise.
    You can make the Hashmap object private and nonstatic and provide a getter method in this class to get the value corresponding to any particular key.
    public Object getValue(String key)
      return egalReviewPieceRelatedACLMap.get(key);
    }

  • How we can get the values  from one screen to another screen?

    hi guru's.
         how we can get the values  from one screen to another screen?
              we get values where cusor is placed but in my requirement i want to get to field values from one screen to another screen.
    regards.
      satheesh.

    Just think of dynpros as windows into the global memory of your program... so if you want the value of a field on dynpro 1234 to appear on dynpro 2345, then just pop the value into a global variable (i.e. one defined in your top include), and you will be able to see it in your second dynpro (assuming you make the field formats etc the same on both screens!).

  • Getting the value of a child node in an array

    How do you get the value of a child node in an array titled "entries"?  I used to do this in AS2, and now I'm trying in AS3.  To top it off, I'm forced to use an XML format I'm unfamiliar with.  So I'm not sure how to access these nodes in AS3.  An example of the XML is;
       <Row>
        <Cell><Data ss:Type="String">Absorption Areas</Data></Cell>
        <Cell><Data ss:Type="String">Drain fields where left over liquid from the septic system soak into the ground.</Data></Cell>
       </Row>
    How would I access ether of the <Cell> rows?
    Thanks

    Given that you declared ss namespace (otherwise it will throw an error) you have two options:
    xml.Cell[0].Data - will output:
    Absorption Areas
    xml.Cell.Data will output:
    <Data ss:Type="String">Absorption Areas</Data>
    <Data ss:Type="String">Drain fields where left over liquid from the septic system soak into the ground.</Data>
    So, xml.Cell.Data[1] will output:
    Drain fields where left over liquid from the septic system soak into the ground.

Maybe you are looking for

  • I can no longer hide apps on the App Store.

    HI, I've been having an issue with hiding apps on the App Store. Up until recently I used to be able to swipe and hide the app from my purchase list but now I can no longer do that. It does give me the option to swipe and hide but it doesn't hide it

  • Problem in periodic job scheduling in LBWE

    hi, i have activated the Material movements datasource 2LIS_03_BF. Filled up the set up table. now when i try to schedula a job in jobcontrol, under the tab *immediate* the immediate start check box is checked and disabled. the periodic job  check bo

  • Does the SQL Server 2012 Express Advance include the Business Intelligence tools?

    I wondered if those tools are included. If so, what's the difference between the express and full version? I only need this for educational purposes.

  • Creating TabStrip control using visual composer

    Hi, I am NW04 version for Visual Composer. I want to create a TabStrip control on which I want to show two table from a RFC. Is there any facility available to create this like NW2004s. I found from some posts that NW04 verson doesn't have capabiliti

  • Getting started with 8i Lite Trial

    I have a copy of 8i Lite that I downloaded from the Oracle site and I have a few questions that I have not been able to answer in the documentation. I want to use this in conjunction with Codewarrior on a Palm platformave a Symbol 1740 Palm-based sca