Creating an array from a csv

Hi all,
I am currently working on a basic app for a masteres dissertation where I am looking to input a number of map pins within the map kit from a csv file I have. The file is in my resources and I have map kit up and running but being an archaeologist rather than a developer this is where I fall down. Any help or advice would be greatly appreciated.
The csv hold over 900 records each looking like this
1783376,Site of Second Possible Contiguous Bronze Age Round Barrow,N 51 11 3.699,W 01 48 37.311,"RCHM 128. A levelled barrow visible as a soil mark on air photos RAF CPE/UK/1811 4354-5, contiguous with 117,574*0.<br /> ( 1980) The field is currently arable ley."
and the titles are;
[0] = Monument ID
[1] = Title
[2] = Latitude
[3] = Longitude
[4] = Descriptions
I guess it would be a Mutable array as the fields will be changing and I looked into creating a FOR loop but as I say I get stuck putting it all together.
Cheers

Here is a link to the book:
http://bignerdranch.com/book/cocoa®_programming_for_mac®_os_x_3rd_edition

Similar Messages

  • Help creating 2D array from tab delimited text file

    I can print the info from the file, but darned if I can't make a 2-D array.
    import java.util.regex.*;
    import java.io.*;
    public final class goodSplitter {
        private static BufferedReader br;
        private static BufferedReader br2;
        private static String INPUT;
        private static int numLines;
        private static int numLine2;
        private static int q;
        private static int t;
        private static int n;
        private static String [][] indexArray;
        public static void main(String[] argv) {
            initResources();
            processTest();
            closeResources();
        private static void initResources() {
           try {
                  br = new BufferedReader(new FileReader("index.txt"));
              System.out.println("found the input file.");
                } catch (FileNotFoundException fnfe)
                   System.out.println("Cannot locate input file! "+fnfe.getMessage());
                          System.exit(0);
           try {
                  br2 = new BufferedReader(new FileReader("index.txt"));
              System.out.println("found file again.");
                } catch (FileNotFoundException fnfe)
                   System.out.println("Cannot locate input file again! "+fnfe.getMessage());
                          System.exit(0);
         try {     
                   int numLines = 0;     
                   while ( ( INPUT = br.readLine( ) ) != null )
                        { numLines++; } // end while
                   System.out.println("file has the number of lines: " + numLines);
                   q = numLines;
                   System.out.println("creating the array.");
                   String [][] indexArray = new String[q][];
                   System.out.println("populating the array.");
                   while ( ( INPUT = br2.readLine( ) ) != null ) {
                        n = t++;
                        System.out.println("first array index = " + n);
                        String[] ss = INPUT.split("\\s");
                        for(int i = 0; i < ss.length; i ++)
                                  System.out.println( new String( ss[i] ) );
                                  indexArray[n] = ss[i];
                             } // end for
                        } // end while
         } catch (Exception e)
              {System.out.println("something went wrong in populating the array of length " + q); }}
    private static void processTest() { System.out.println("processed text."); }
    private static void closeResources() {
    try{ br.close();  }catch(IOException ioe){} }

    you haven't sized the 2nd part of the 2d array
    add this line
    String[] ss = INPUT.split("\\s");
    indexArray[n] = new String[ss.length];//<--------------
    for(int i = 0; i < ss.length; i ++)
    but note you have declared indexArray both as a class variable
    private static String [][] indexArray;
    and a variable local to the try/catch block
    String [][] indexArray = new String[q][];
    probably what you want is
    indexArray = new String[q][];

  • Help creating an array from a list of vector item

    I am writing a Email Handling class that uses an Email class that I have already written. The spec requires me to (A.) Create a DisplayEmail(Email[] e) method that takes and array of email messages and displays them in the terminal window. And then (B) to create some retrieval methods ie: Email [] RetrieveSubject(String searchValue) which "will allow me to retrieve objects from the data structure created in (A.)and sorts them.
    I wonder if you could give my some advice on how to implement this? I have used a Vector to store the emails. Here is what I have so far. . From what I understand I am suppose to create array methods for all of these tasks. Don't know where to begin, can u help please. I've created a vector to store the emails, but I am not sure about the array method bit. As you can see all of my methods are standard and I think they need to be arrays. Please Help
    import java.util.*;
    public class EmailHandler{
    private Vector emails;
    public EmailHandler(){
         emails = new Vector();
    public EmailHandler(int size){
         emails= new Vector(size);
    public void addEmail(Email e){
         emails.addElement(e);
    public void displayEmail(Email de)
    public void displayArrayOfEmails(Email[] ea)
    public Email RetrieveSender(String searchSender)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getSender().equalsIgnoreCase(searchSender))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;
    public Email RetrieveRecipient(String searchRecipient)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getRecipientName().equalsIgnoreCase(searchRecipient))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;
    public Email RetrieveSubject(String searchSubject)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getSubject().equalsIgnoreCase(searchSubject))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;

    i've anwered your question in your crosspost over here:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=472997&tstart=0&trange=30

  • Unable to create shared mailboxes from a csv file

    Hi,
    I have a list of 130 shared mailboxes that I must create. So I created a CSV file like this:
    Name,Alias,OrganizationalUnit,Database,UserPrincipalName
    John Smith,jsmith,domain.com/accounts/shared,mailbox database A,[email protected]
    Mark Flone,mflone,domain.com/accounts/shared,mailbox database A,[email protected]
    ETC.....
    The list is ready and it is saved.
     import-csv C:\path | New-mailbox -Shared
    the Error is the following:
    "Cannot bind parameter 'Name' to the target. Exception setting "Name": "The property can't be empty."
    I went into my spreadsheet and Trimmed everything, then saved and still the same error result.
    Then I tried the following:
    import-csv C:\temp\sharedMailboxCreationTest.csv | ForEach-Object {New-Mailbox -shared  -Name $_.Name  -Alias $_.Alias  -OrganizationalUnit $_.OrganizationalUnit -UserPrincipalName $_.UPN -Database $_.Database}
    The Error:
    "Cannot bind argument to parameter 'UserPrincipalName' because it is an empty string."
    What am I missing here?
    Alexis

    You have UserPrincipalName column heading in the csv file so this should be your cmdlet.
    import-csv C:\temp\sharedMailboxCreationTest.csv | ForEach-Object {New-Mailbox -shared  -Name $_.Name  -Alias $_.Alias  -OrganizationalUnit $_.OrganizationalUnit -UserPrincipalName $_.UserPrincipalName -Database $_.Database}
    Blog |
    Get Your Exchange Powershell Tip of the Day from here

  • Creating a array from variables passed from php

    I have passed variables from PHP to flash successfully but
    now need to firstly make them into an array. A next button and
    previous button has to trigger the step through the array.
    Any ideas?

    I have a PHP script and I get flash to load the variables
    from it. The code is as follows. Taken out the connection to DB for
    security.
    <?php
    $hostname_conn = "";
    $database_conn = "";
    $username_conn = "";
    $password_conn = "";
    // establish a SQL connection to the host - host, user, pass
    $conn = mysql_pconnect($hostname_conn, $username_conn,
    $password_conn) or trigger_error("The site database appears unable
    to provide a connection. Please contact support.
    ".mysql_error(),E_USER_ERROR); // or die("The site database appears
    unable to provide a SQL connection. Please contact support.");
    // connect to the right DB (there may be multiple db's on the
    server) dbName
    mysql_select_db($database_conn, $conn) or die("The site
    database appears to be unavailable. Please contact support.");
    $qCheck = "SELECT * FROM pics";
    $rsCheck = mysql_query($qCheck) or die("Check Failed :
    ".mysql_error());
    $cCheck = mysql_num_rows($rsCheck);?>
    &img=<?php
    while($row= mysql_fetch_assoc($rsCheck))
    print($row["img"]);
    ?>

  • Importing custom created security profiles from a .csv or .xls document

    Hi Experts,
    We have a prerequisite where we need to create custome security profiles as per the requirement.
    These security profiles I have created in an excel sheet and wish to import it in the server.
    The reason behind creating the security profiles through excel sheet is that in the future we will be working on a new server. So instead of doing any rework we can directly import from this excel sheet.
    For creating a security profiles through an excel sheet, I have mentioned the following things in the excel sheet.
    1. In a "eso_security_profiles" i have mentioned the profile name,description,internal ID, etc..
    DISPLAY_NAME       DOCUMENT_DESCRIPTION    INTERNAL_NAME     CATEGORY  COLLAB_PROFILE    INTERNAL_TYPE     RESTRICTED
    DISPLAY_NAME:Category Manager    
    DOCUMENT_DESCRIPTION   : This profile is for the user who has full rights only at project business document but cannot approve and have no access rights to the master data
    INTERNAL_NAME  :  fci.profile.doc.category_manager
    CATEGORY  :   BUYSIDE     
    COLLAB_PROFILE    :   TRUE     
    INTERNAL_TYPE     :   
    RESTRICTED   :  
    2. And in the "eso_security_rights" I have mentioned the access rights as per requirement.
    RESOURCE        SECURITY_PROFILE                               ALLOW_PERMISSIONS       DENY_PERMISSIONS
    rfx.RFXDoc        fci.profile.doc.wft_category_manager     ODP_READ
    Please give some inputs on this. Am not sure if what I have done is the right way.
    Thanks.
    Vaishali.

    Hi Vaishali,
    I understand that you need these security profiles in another server going forward. I would suggest another way around rather.
    Please create the Security profiles in SAP Sourcing itself, then export the OMA file. When you move into another server please import this OMA file. This will serve the purpose of having the new security profiles in the new server.
    If you are modifing something in the workbook, then you should carefully review field details. As I am not sure which version of SAP Sourcing and details of workbook, so I would suggest the above way to try out.
    Hope this helps
    Thanks
    Jagamohan

  • Create Array from Record

    Hi
    Somebody have a example how can I to create a Array from record ?
    tks

    Hi!
    Pls go through the followinglink --
    [url http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10807/05_colls.htm]VArray From Record In Oracle
    Hope that will help u.
    Regards.
    Satyaki De.

  • Programmatically create array from common cluster items inside array of clusters

    I have seen many questions and responses on dealing with arrays of clusters, but none that discuss quite what I am looking for. I am trying to programmatically create an array from common cluster items inside array of clusters. I have a working solution but looking for a cleaner approach.  I have an array of clusters representing channels of data.  Each cluster contains a mixture of control data types, i.e.. names, types, range, values, units, etc. The entire cluster is a typedef made up of other typedefs such as the type, range and units and native controls like numeric and boolean. One array is a “block” or module. One cluster is a channel of data. I wrote a small vi to extract all the data with the same units and “pipe” them into another array so that I can process all the data from all the channels of the same units together.  It consists of a loop to iterate through the array, in which there is an unbundle by name and a case structure with a case for each unit.  Within a specific case, there is a build array for that unit and all the other non-relevant shift registers pass through.  As you can see from the attached snapshots, the effort to add an additional unit grows as each non-relevant case must be wired through.  It is important to note that there is no default case.  My question:  Is there a cleaner, more efficient and elegant way to do this?
    Thanks in advance!
    Solved!
    Go to Solution.
    Attachments:
    NI_Chan units to array_1.png ‏35 KB
    NI_Chan units to array_2.png ‏50 KB

    nathand wrote:
    Your comments made me curious, so I put together a quick test. Maybe there's an error in the code (below as a snippet, and attached as a VI) or maybe it's been fixed in LabVIEW 2013, but I'm consistently getting faster times from the IPE (2-3 ms versus 5-6ms for unbundle/index). See if you get the same results. For fun I flipped the order of the test and got the same results (this is why the snippet and the VI execute the tests in opposite order).
    This seems like a poster child for using the IPES!  We can look at the index array + replace subset and recognize that it is in place, but the compiler is not so clever (yet!).  The bundle/unbundle is a well-known "magic pattern" so it should be roughly equivalent to the IPES, with a tiny penalty due to overhead.
    Replace only the array operation with an IPES and leave the bundle/unbundle alone and I wager the times will be roughly the same as using the nested IPES.  Maybe even a slight lean toward the magic pattern now if I recall correctly.
    If you instantly recognize all combinations which the compiler will optimize and not optimize, or you want to exhaustively benchmark all of your code then pick and choose between the two to avoid the slight overhead.  Otherwise I think the IPES looks better, at best works MUCH better, and at worst works ever-so-slightly worse.  And as a not-so-gentle reminder to all:  if you really care about performance at this level of detail: TURN OFF DEBUGGING!

  • Scripting: Create Cluster in Array from existing cluster

    I am creating a custom programming tool to generate some custom LabVIEW TypeDefs.
    One of the structures I have to create is an array of clusters; but from an existing cluster.  That is, I have a reference to a previously defined cluster, and I need to array this.
    One possible way to do this is to duplicate the cluster next to the empty array, and then 'move it into' the array.  This seems to be an ugly solution.
    Is there a better way?  When I try and use "Create from Reference" method, the cluster is created in the array, but the sub-elements trigger error 0x421: Type Mismatch.
    Thanks!
    Jed

    Hi Viper,
    Sorry- you misunderstand.  We are talking about doing this with LV Scripting; what you did statically defines the array type in the VI.  Writing LV code that would create the array from an undefined array by running a VI.  (In the situation above, the code would actually EDIT the VI and change it's functionality)
    There are a few examples in the distro if you search for "scripting", but here's a page with some example code you can look at.
    http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/wiring_scripting_objects/

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • Automator: Create new folders from .csv file and put images inside.

    I have a challenging Automator task to achieve. I need to
    1) create a set of folders labeled with the contents in column A of a csv file. (example: column A1 JoeBrown A2 SuzyBrown A3 JimBrown etc..) resulting in
    3 folders titled JoeBrown, SuzyBrown, and JimBrown
    2) take the image represented by an image number in column B of the same csv file and move that file into the folder that was created (example: A1 JoeBrown gets a folder created by the name JoBrown and column B IMG_1234.jpg is physically moved from within the same folder as the .csv file into the folder created by column A.
    Both the csv and img files would be in the same folder. I have the script to create a set of folders from a csv list just can't complete the moving of files based on the contents of column B.
    SUMMARY: I have a folder containing several images img_0001, img_0002, img_0003 etc. and a csv file that contains columnA a series of names and column B a series of jpg image numbers. I need to have a script that will create folders labeled whatever name is in column A (see the script below. it works great!) then move the images from column B to the folders generated from column A.
    The csv script is:
    tell application "Finder"
      set mgFolder to container of mgCSVfile as string
      repeat with x from 1 to count paragraphs of mgList
        set text item delimiters of AppleScript to ","
        set mgThisList to text items of paragraph x of mgList as list
        set text item delimiters of AppleScript to ""
        set mgTopFolder to item 1 of mgThisList
        if (exists folder mgTopFolder of folder mgFolder) is false then
          make new folder at mgFolder with properties {name:mgTopFolder}
        end if
        set mgNewFolder to (folder mgTopFolder of folder mgFolder) as alias
        repeat with i from 2 to count mgThisList
          if item i of mgThisList is not "" then
            set mgSubFolder to item i of mgThisList
            if (exists folder mgSubFolder of folder mgNewFolder) is false then
              make new folder at mgNewFolder with properties {name:mgSubFolder}
            end if
          end if
        end repeat
      end repeat
    end tell
    Thanks for any help that may come my way.

    This should work
    (assumes a true "," seperated file with only two items per line, i.e.: Test,Test.jpg):
    The Run Shell Script Action is:
    cd "${1%/*}"
    while read line         
    do         
         FolderName=${line%,*}
         ImageName=${line#*,}
         mkdir "$FolderName"
         mv "$ImageName" "$FolderName"
    done < "$1"

  • Formatted .data file, reading in and creating an array of objects from data

    Hi there, I have written a text file with the following format;
    List of random personal data: length 100
    1 : Atg : Age 27 : Income 70000
    2 : Dho : Age 57 : Income 110000
    3 : Lid : Age 40 : Income 460000
    4 : Wgeecnce : Age 43 : Income 370000
    and so on.
    These three pieces of data, Name,Age and Income were all generated randomly to be stored in an array of objects of class Person.
    Now what I must do is , read in this very file and re-create the array of objects that they were initially written from.
    I'm totally lost on how to go about doing this, I have only been learning java for the last month so anyone that can lend me a hand, that would be superb!
    Cheers!

    Looking at you other thread, you are able to create the code needed - so what's the problem?
    Here's an (not the only) approach:
    Create an array of the necessary length to hold the 3 variables, or, if you don't know the length of the file, create a class to contain the data. Then create an ArrayList to hold an instance of the class..
    Use the Scanner class to read and parse the file contents into the appropriate variables.
    Add each variable to either the array, or to an instance of the class and add that instance to the arraylist.

  • How to create an array in one field and have another field display certain elements from that array?

    I am making a form in Acrobat XI pro.
    In one text field, I created an array of several elements. I want other text fields to display certain elements from that array. For instance, one field should display the 3rd element, another field should display the 13th element, etc.
    The Javascript for making the array is very long, and so I don't want to have to re-calculate the array every single time (in order to reduce rendering time when I open the form on an iPad). This is why I'd like to only have to create the array once, and simply refer to it throughout the form.

    What code are you using to update the array currently? Are you completely rebuiding it when an element changes, or just changing specific elements for certain fields? I'm still not sure what exactly you are trying to do, but something like this in a document level script will create your array:
    var myArray;
    // Call 'updateArray' to initialize array
    updateArray();
    function updateArray() {
         // Code here to create/update array
         myArray = new Array();
         myArray[0] = "Value 1";
         myArray[1] = "Value 2";
         myArray[2] = "Value 3";
    Then, for each field that needs to update this array, you can add a call to 'updateArray()' in the appropriate event. This will rebuild the array completely; if you just want to update specific elements, then you can access them directly.

  • Best way to create array from sampled signal???

    I'm not sure exactly how to pose this question (been using labview for less than 2 weeks). I'm trying to graph the position of a motorized stage being run though an old Newport controller. I can obtain the position no problem. My sub-routine to get the position is in a while loop that repeats every 200 ms. I added a shift register to keep create an index to make the array, but it only stores the final position in the middle of the array, and puts zeros everywhere else (I initialized a large array outside the loop so it's basically just not writing anything except for that one value).
    When I use the probe the index and position values change together, I just don't understand why it doesn't store.
    Sorry if this is vague, I'm just not sure how to store these values to plot them. Any help is apprecated.
    Thanks
    Tim

    I'm unclear from you message exactly what you are doing with the shift register, but if you create an array outside the loop, of the maximum size expected (with a little more in case your guestimate is wrong) then use the loop index to index a "replace array subset" to replace the 0 value with your new value. Alternatively, create a null array of the right data type (an array constant) and do an append. Or just lead the value to the loop edge and enable indexing. The first two allow you to "see" the array during the running, the later one only allows you to see the results when the loop is stopped.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion
    Attachments:
    adding to loop.vi ‏43 KB

  • Creating an arrays of objects from a class

    I was wondering does any one know how to create an array of objects from a class?
    I am trying to create an array of objects of a class.
    class name ---> Class objectArray[100] = new Class;
    I cant seem to make a single class but i need to figure out how to create an array of objects.
    I can make a normal class with Class object = new Class

    There are four lines of code in your for-loop that actually do something:
    for(index = 0; index < rooms.length; index++) {
    /*1*/  assignWidth.setWidth(Double.parseDouble(in.readLine()));
    /*2*/  rooms[index] = assignWidth;
    /*3*/  assignLength.setWidth(Double.parseDouble(in.readLine());
    /*4*/  rooms[index] = assignLength;
    }1.) Sets the width of an object, that has been instantiated outside the loop.
    2.) assigns that object to the current position in the array
    3.) Sets the width of a second object that has been instantiated outside the loop
    4.) assigns that other object to the current position in the array
    btw.: I bet you meant "assignLength.setLength(Double.parseDouble(in.readLine());" in line 3 ;)
    Since each position in an array can only hold one value, the first assignment (line 2) is overwritten by the second assignment (line 4)
    When I said "construct a new room-object and assign it to rooms[index]" I meant something like this:
    for(index = 0; index < rooms.length; index++) {
        Room aNewRoom = new Room();
        aNewRoom.setWidth(Double.parseDouble(in.readLine()));
        aNewRoom.setLength(Double.parseDouble(in.readLine());
        rooms[index] = aNewRoom;
    }1.) Constructs a new Object in every iteration of the for-loop. (btw: I don't know what kind of objects you're using, so this needs most likely modification!!)
    2.) set the width of the newly created object
    3.) set the length of the newly created object
    4.) assign the newly created object to the current position in the array
    -T-
    btw. this would do the same:
    for(index = 0; index < rooms.length; index++) {
        rooms[index] = new Room();
        rooms[index].setWidth(Double.parseDouble(in.readLine()));
        rooms[index].setLength(Double.parseDouble(in.readLine());
    }but be sure you understand it. Your teacher most likely wants you to explain it ;)

Maybe you are looking for

  • Develop the custom report on payload

    Hi I want to develop a report on the basis of payload  in XI for eg  i send some sales order , then sales order no ,time of sending ,receiving at the other end , success  etc Regards Vijay

  • I cannot figure out how to download iPhoto 9.6 on my reset Mac.

    Help.  I had iPhoto on my Mac but then I had to have it rebooted to Factory Settings and I can no longer get it.  When I try to install it says that the computer needs to be 10.10 and mine is 10.9.  Any solutions?  Thanks!

  • Need help choosing P.Book 12" or 15" or 17"?

    Hi, I am having the exactly same issue asa many other people on this forum. I was waiting for the MacBook and now its out and I can't buy it because there is no software and won't be for a while. Well anyways, I need a comp and like a sucker will buy

  • Retract Action Menu Selection for EQ - Does this require configuration?

    We are currently on version 6.1.0.1 - under the eQ action menu of a sent eQ is the "Retract" action. When I select this action for an "InProgress eQ", nothing happens and the eQ status does not change. When I searched the configuration, navigation, a

  • How can I make a disk image of an unmountable disk?

    I have an external La Cie USB 3 disk that refuses to mount. I'd really like to get the data off of it. I recently had another external disk die the clicking death and I found a utility that made a disk image of that disk, but now I cannot find the ut