Array manipulati​ons...

Hi
I would like some help with array manipulation
I have multiple  files (1000 text files) with 5 columns each and 20,000 rows. The first row of each file has a header that labels the columns.
I would like to be able to read each of these files, pull out colum 3 from each file and then build these into a new 2D array. It would be nice if they also had their corresponding header labels. So then I would end up with the new 2D array containing 1,000 columns (corresponding to column 3 of each of my 1000 files) with 20,000 rows plus a first row with the header labels.
I would also like the option to in future select column 2 for example, or column 5; plus I would also like the functionality to allow me to perhasp pull out more than one colum, e.g. colum 2 and 3, before we build the new array.
I hope I made some sense and that someone can help. Thanks you

Oh nuts! 
While I was trying link those posts to give a heads up to the forum I had a sinking feeling that I was going to get it all wrong.
I need to be more mindful of my feelings ....
cheers
David

Similar Messages

  • JS CS3 Change geometricBounds

    Hi
    When I run:
    app.selection[0].geometricBounds = [0,0,10,10];
    everything works as expected.
    I only want to change the width so I tried:
    app.selection[0].geometricBounds[3] += 10;
    or
    app.selection[0].geometricBounds[3] = app.selection[0].geometricBounds[3] + 10;
    nothing changes and no error message appears.
    I solved it in the following clumsy way eventually:
    a = app.selection[0].geometricBounds[0];
    b = app.selection[0].geometricBounds[1];
    c = app.selection[0].geometricBounds[2];
    d = app.selection[0].geometricBounds[3] + 10;
    app.selection[0].geometricBounds = [a,b,c,d];
    So it finally kind of works but it leaves me scratching my head. Is this really the way to do it?
    Thanks for clarification
    weller

    I would do it this way:
    myBounds = app.selection[0].geometricBounds;
    myBounds[3] = myBounds[3] + 10;
    app.selection[0].geometricBounds = myBounds;
    The point is that because the property is an array, you must set it with an array -- if you try to manipulate a member of the array, what happens is that ExtendScript creates a temporary version of the array, manipulates that and it is left hanging out there with no effect.
    Dave

  • Invert a button's image icon colors?

    I have an image (bmp) that I put on a button using its imageicon.
    I want to be able to invert the colors of that image(basically its a black and white image) and I'd
    just like to be able to pass in the byte array manipulate it somehow and get back a byte array
    with inverted colors...
    or does anyone know if Jimi or JAI has a function that takes in a picture and returns an inverted one??
    could anyone help with that please??
    thanks!!!

    Try it an see if it works.
    yourImage = GreyFilter.createDisabledImage (yourImage);If it doesn't work, the source is only 84 lines even with comments. Copy it into you own BWFilter class and expirement untill you get something that works.
    Good luck,
    Todd

  • OBPM Studio newbie 101 question - how do I manipulate arrays ?

    Hi :-)
    I've RTFM'd but couldn't find the answer so here goes.
    I'm using Java syntax and would like to manipulate my array like so:
    String[] foo = new String [  100  ];
    Unfortunately the above gets flagged as an error and I have no clue why. If I separate the above into two statements then I get the following results:
    String [] foo; <-- ok
    foo = new String [ 100 ] <-- error
    Using a static array e.g. String[] foo = { "foo" } is not an option for me because the array size can be variable.
    I must be missing something fundamental here ... appreciate your guidance pls. :-) Thanks
    PS: Somehow the left and right square brackets are stripped out from my post

    Hi,
    I would like to comment something.
    When you create a String array, behind the scenes, bpm is using a list. That's why you can not specify the array size.
    You can add elements in the following way:
    String[] arr;
    arr[] = "Fisrt element";
    arr[] = "Second element element";
    display(arr.toString());
    Hope this helps,
    Ariel

  • Manipulati​on of Array Data

    I would like to be able to manipulate some data (columns 2 and 3 of txt file) that I am collecting as a function of time (column 1 of txt file).
    Right now, as the VI is running, this data is being plotted on a waveform chart and saved to txt file.
    What I need to do is:
    Column 1 - Convert each time point to a wavelength.  I know starting wavelength (nm) and rate of change of wavelength (nm/sec).  I do this conversion on an excel spreadsheet right now where [current wavelength = previous wavelength - rate of change of wavelength*(current time-previous time)].  So how do I extract column one, take the difference between the second value and the first value, and create a new column (somewhere) corresponding to wavelength?  And save to a new column?
    Column 2 - Need to divide each value by 100 and subtract by a "baseline" (an average of the first 20 points, for instance).
    Column 3 - As is.
    Final step - Write to file a new column defined as manipulated column 2 divided by column 3 times 100...and then plot this (on y-axis) as a function of manipulated column 1 (x-axis). 
    It's not incredibly critical that the data manipulation occur in real-time...it can happen after the file has been written if necessary.  The final graphical result should look like the attached jpeg.
    Thanks in advance for the help - I'm a little uncertain about array conversion, unbundling, etc. nevermind the mathematical differences and averages that need to be obtained.
    Meredith
    Solved!
    Go to Solution.
    Attachments:
    Example Spectrum.jpg ‏36 KB
    Example Spectrum Data.txt ‏323 KB

    hello,
    i tried to make what i understood , see if it make sense
    few textual details in vi, two jpg attached in case your 're not LV8.6
    look at xy result to see if that talk to you , not for me 
    Best regards 
    Tinnitus
    CLAD / Labview 2011, Win Xp
    Mission d'une semaine- à plusieurs mois laissez moi un MP...
    RP et Midi-pyrénées .Km+++ si possibilité de télétravail
    Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
    Don't forget to valid a good answer / pensez à valider une réponse correcte
    Attachments:
    spectrum.vi ‏21 KB
    spectum_code.jpg ‏131 KB
    specto_xy.jpg ‏123 KB

  • Manipulate 2-D arrays

    I need to add several 512 by 512 arrays and do arithmetic manipulations on them(multiply, divided, etc).  these arrays are 16 bit unsigned short and I am afraid that some of the entries will overflow as I add on more arrays, how do I get around this problem?
    Can a computer learn how to program?

    You could convert them to DBL at the beginning, using the conversion bullet.
    (For division the output will be DBL anyway)
    Message Edited by altenbach on 12-16-2005 09:39 AM
    LabVIEW Champion . Do more with less code and in less time .

  • How to manipulate arrays using case statements and boolean conditions?

    In the vi that is attached I am trying to compare two values in two different arrays and delete the value that is equal to zero.  The values of each array are rounded to the closest integer.  Then I attempted to apply the ">0" boolean as the condition for my case statement, but I am getting an error.  Any tips on manipulating arrays with case statements?
    Attachments:
    Patient Movement Monitoring.vi ‏141 KB

    Thank you!!! that was a huge help. I don't think I need the case structures at all.  The next part of the code compares the 4 values in the array. 
    If columns 0 and 1 are both positive -> output 1
    If column 0 is negative and 1 is positive -> output 2
    If columns 0 and 1 are both negative -> output 3
    If column 0 is positive and 1 is negative -> output 4
    (0 is x-axis value, 1 is y-axis value.....outputs are assigning quadrants to the combination)
    Only one of the "AND" booleans will return true for each index.  Is there a way to initialize another array of outputs 1-4 depending on which AND returns true?
    Attachments:
    Patient Movement Monitoring.vi ‏144 KB

  • Manipulati​ng 2D arrays

    I'm fairly new to labview and working on a VI that I am taking over.
    The VI has channels 0-31 (channels 0-3 are being used for a photo sensing diode).  In a while loop I am oversampling data at 1000 points/sec and the plan is to average 1000 pts and plot only the average per second.  I have a 2D array being piped out of the DAQmx Read (Analog 2D DBL NChan NSamp).  I am assuming the 2D array is the channel numbers and the data for each iteration.  I figured I'd transpose the array (to get the channel numbers in a row so I can isolate it), take 2 array subsets, one with index 0 and length 1 (I think this is wrong but I figured I would just get the first row and only the first row, but I seem to get an output of a 2D array), and the other with index 4 (since I don't want the photo diode channels) with no set length so it will take all the remaining data values.  Then I transposed the latter array so I can take averages of the elements.  I am thinking I get a column of averages of channels 4-31.
    So now I have a row of my channels from 0-31 and a column of averages from 4-31.  The data needs to be thrown back into a 2D array to be written to the file.  Currently the output of the DAQmx is split and piped to an index array function that sends the photodiode channels to lock-in amps and straight down to be written to the file.
    What can I do?  I am confused and obviously don't know enough to complete my task.  Any help is greatly appreciated.
    Attachments:
    average problem.JPG ‏205 KB

    First off, I didn't create this VI, so I am really confused as to what is going on.  So I agree.  And the picture was just to show where I am starting from.  My ideas haven't been implimented, for reasons such as...I don't know much of what I'm doing.  I know it's a pain when someone as new to labview as I am posts questions.  The person who worked on this VI moved and it's part of an ongoing research project.  So a newbie like me was thrown into it, and it's a steep learning curve!  The data that is split out of the DAQmx (that just goes down to the file) is what I need to average.  I expected a 1D array of just one data point per channel to come out of the DAQmx but I get a 2D array.  So I am really confused.  Thanks for looking at it anyway.  I don't think I can really say much more other than the basics that I just need to take that 2D array and average the oversampled data.  One application is that we are taking temperature data and there is a lot of noise so we need to average those channels.  And since the other channels will be used eventually, we just wanted to average each channel, and throw it back into a 2D array.
    I can post the VI when I go back to the lab tomorrow if that might help, but I'm quite lost.
    thanks again,
    nathan

  • Using an array to manipulate SMC100 stage position

    Hi, 
    I am new to labVIEW. I am trying to take an image at various positions with the stage so I have to make create an array which I am not sure how to do it. For example, I want the stage to move from 10 ps - 1ps (in 1ps interval),  from1 ps - 2ps (in 100 fps interval) and from 2ps - 5ps (in 1ps interval) then when I run the program it will automatically does according to the array. Any thoughts how can I do this ? 
    Many thanks in advance,
    sdozai 

    You don't need to initialize the camera or the stage with each loop. You can move that outside of the loop. You also don't need the sequence structure since your data flow should make everything run in order.
    There are a lot of different way to set up this VI and you're not really doing it just right, but I'm not sure exactly how you want it to operate. Since you're new to LabVIEW, you could two one of two things. You can stumble through this VI and make it work by adding Wait nodes in there, or you can go research LabVIEW programming techniques to become more familiar with the programming practices. There is a 3 hour video and a 6 hour video on the basics, I suggest you take a look.

  • Array Allocation and Memory

    I can create this array without a problem:
    private float[][][] floats = new float[170][170][170];
    This one causes an error:
    private float[][][][] floats = new float[170][170][170][1];
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    I am using -J-Xms350m and -J-XX:MaxPermSize=500m
    Setting Xms350m to 400 stops Netbeans from starting, even though I have 3GB ram, and 50% of my physical memory is available according to taskmanager.
    I need to have three of the following array:
    private float[][][][] floats = new float[169][169][169][15];
    How can I do this so that the program will run in JVM?
    Do I have to switch to another language, such as C, for this?
    I actually do need to use all of this memory at once. There is nothing that I can do to reduce it. I have millions of unique values to store and manipulate.

    cyzo wrote:
    Its "The only IDE you need."
    I can run netbeans with "-J-Xss2m -J-Xms128m -J-Xmx1000m -J-XX:PermSize=32m -J-XX:MaxPermSize=512m"
    I still get the heap size error.-Xmx1000m is for your java application and not for the NB ide. Did you get me correct?
    $>java -cp yourClassPaths -Xmx1000m yourJavaApplication

  • Arrays of arrays or list of arrays?

    Hi!
    I've spent 2+ hours now trying to figure this out/browsing the web.
    I have x number of rows in db, and now I'm trying to convert this data to an array.
    Like this:
    String foo[] = null;
    Array unordered[];
    int i=0;       
    while(ResultSet.next()){
       foo = new String[]{  ResultSet.getString("osa_id"),
                            ResultSet.getString("k_teksti"),
                            ResultSet.getString("linkki"),
                            ResultSet.getString("taso"),
                            ResultSet.getString("k_alaisuus")};
       unordered[i] = valiaikainen;
       i++;
    }Compiles, but gives errors during run. In PHP this is annoyingly easy. (Grin.) Also I have to manipulate the order of the unordered, depending the data that arrays it contain holds. Is there easier way? Any help welcome, as I'm out of ideas.
    Thanks
    -9902468

    OOps. Stopid question.
    Figured it out right after posting the question...
    Well newbies are newbies, eh?
    -9902468

  • Associative Array our only option?

    Hello,
    I'm having a problem accepting associative arrays as the only option I have for getting data from a stored procedure. I have a good reason for not wanting to use ref cursors as I am using the stored procedure to manipulate data which I in turn would like to pass back to VB through the stored procedure and would rather not have to insert he data into a table just to re-select it for a ref cursor.
    My main concern is that with associative arrays I am expected to define the number of return results before I even generate the data. Also from what I can see I am required to set the data length for each and every item in said array one at a time. All this overhead seems like more work than what I would have to do to utilizer a reference cursor. Is there a right way to do this? I would really like to do the most straight forward way I can without the extra processing.

    Hi,
    Here's a blog post of mine that illustrates using pipelined functions and PL/SQL to return results:
    http://oradim.blogspot.com/2007/10/odpnet-tip-using-pipelined-functions.html
    Not sure if that will be helpful in your case, but perhaps it might be a place to start anyway.
    - Mark

  • What happens to the array built inside a subvi

    Hi
    My operation inside a subvi goes like this, i acquire data from a source continuously in a loop, build it in the loop and pass it out of the loop. I complete the processing of the built array in the same subvi and come out of it.
    I have the following doubts ;
    1. Does the memory allocated for building the array gets cleared when i come out of the sub vi.

    The answer is no, the memory allocated by the sub-VI will not be released, it will remain in use until the next time the sub-VI is called...then it might reduce or increase it's size depending on how it works. You can improve the performance by ensuring that the VI always works on the same memory (do not build arrays but initialize a shift register only at the first run and then use the replace array elements function instead e.g.). Building arrays in a loop is a no no.
    If the VI is only to run now and then you can force the memory to be released either by loading the VI dynamically and then closing all references to it when you are finished with it for that run...or you can use the Request Deallocation function that you can find on the advanced -> data manipulati
    on menu in LV7. If the VI runs all the time your better off leaving it in memory.
    MTO

  • How do I read directly from file into byte array

    I am reading an image from a file into a BuffertedImage then writing it out again into an array of bytes which I store and use later on in the program. Currently Im doing this in two stages is there a way to do it it one go to speed things up.
    try
                //Read File Contents into a Buffered Image
                /** BUG 4705399: There was a problem with some jpegs taking ages to load turns out to be
                 * (at least partially) a problem with non-standard colour models, which is why we set the
                 * destination colour model. The side effect should be standard colour model in subsequent reading.
                BufferedImage bi = null;
                ImageReader ir = null;
                ImageInputStream stream =  ImageIO.createImageInputStream(new File(path));
                final Iterator i = ImageIO.getImageReaders(stream);
                if (i.hasNext())
                    ir = (ImageReader) i.next();
                    ir.setInput(stream);
                    ImageReadParam param = ir.getDefaultReadParam();
                    ImageTypeSpecifier typeToUse = null;
                    for (Iterator i2 = ir.getImageTypes(0); i2.hasNext();)
                        ImageTypeSpecifier type = (ImageTypeSpecifier) i2.next();
                        if (type.getColorModel().getColorSpace().isCS_sRGB())
                            typeToUse = type;
                    if (typeToUse != null)
                        param.setDestinationType(typeToUse);
                    bi = ir.read(0, param);
                    //ir.dispose(); seem to reference this in write
                    //stream.close();
                //Write Buffered Image to Byte ArrayOutput Stream
                if (bi != null)
                    //Convert to byte array
                    final ByteArrayOutputStream output = new ByteArrayOutputStream();
                    //Try and find corresponding writer for reader but if not possible
                    //we use JPG (which is always installed) instead.
                    final ImageWriter iw = ImageIO.getImageWriter(ir);
                    if (iw != null)
                        if (ImageIO.write(bi, ir.getFormatName(), new DataOutputStream(output)) == false)
                            MainWindow.logger.warning("Unable to Write Image");
                    else
                        if (ImageIO.write(bi, "JPG", new DataOutputStream(output)) == false)
                            MainWindow.logger.warning("Warning Unable to Write Image as JPEG");
                    //Add to image list
                    final byte[] imageData = output.toByteArray();
                    Images.addImage(imageData);
                  

    If you don't need to manipulate the image in any way I would suggest you just read the image file directly into a byte array (without ImageReader) and then create the BufferedImage from that byte array.

  • How to manipulate a javascript object in java?

    Hi, I am fiddling with the java scripting interface. As I understand the rhino engine is packaged with the jdk but what I don't understand is how does one reconcile the objects one gets from their engine (e.g. sun.org.mozilla.javascript.internal.ScriptableObject) versus the ones in the rhino api (e.g. org.mozilla.javascript.ScriptableObject)?
    Is the one in the jdk heavily modified or wrappered up to suit their javax.scripting interface?
    More specifically, how do I manipulate javascript objects from java?
    e.g. suppose I have this java code:
    ScriptEngineManager mgr = new ScriptEngineManager();
    ScriptEngine js = mgr.getEngineByName("js");
    jsEngine.eval("var foo = { x : 1, y : 'hello', z : false };");
    Object o = jsEngine.get("foo");Now o is instanceof sun.org.mozilla.javascript.internal.NativeObject, which is a subclass of a bunch of other classes in the s.o.m.j.i namespace. Being internal I can't use these directly.
    Looking at the Rhino API obviously you normally get a org.mozilla.javascript.ScriptableObject and can call the .get() .getIds() methods. But I don't know how to translate the objects I am getting in my actual java code which uses the jdk engine into org.mozilla.javascript objects.
    Is this even possible? Am I misunderstanding something completely? Should I just be using the rhino js jar and not the javax.scripting interface? If so, for what reason is the javax.scripting interface implemented?

    Assuming that you DO want a deep copy, begin with a constructor that takes another hand.
    public Hand( Hand h ) { ...Then for each instance variable, within that constructor:
    this.instVar0 = h.instVar0;
    this.instVar1 = h.instVar1;
    . . .And last, for every reference, make sure there is a constructor (or copy method for arrays) that itself makes a deep copy:
    this.ref0 = new Ref0Type( h.ref0 );

Maybe you are looking for