• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    CSV as data points

    User help
    2
    6
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jerrod Tanner
      last edited by

      Hi, I am very new to Mango and have been working on taking CSV files and making their columns into data points. I used the default multi column CSV importer which works fine, I get my columns as data points inside my CSV data source in Mango. My issue is that it will only create points for the last row. How can I get all or even a select few rows?

      1 Reply Last reply Reply Quote 0
      • MattFoxM
        MattFox
        last edited by

        I'd advise showing us a copy of your CSV for what you're trying to insert then perhaps we can point out if an oversight has been made or recommend a new CSV importer class to import your data. Remember to use the code tags (</>)!

        Fox

        Do not follow where the path may lead; go instead where there is no path.
        And leave a trail - Muriel Strode

        1 Reply Last reply Reply Quote 0
        • J
          Jerrod Tanner
          last edited by

          0_1593712964341_4663f5f5-5153-4a33-9864-e5aa6c5d967f-image.png

          public class MultiColumnCsvImporter extends AbstractCSVDataSource {
          	
          	private Map<Integer, String> headerMap = new HashMap<Integer, String>();
          	
          	
          	@Override
          	public void importRow(String[] row, int rowNum) {
          		//Strip out the header row, it does not contain our data
          		if(rowNum == 0){
          			for(int k = 0; k < row.length; ++k) {
          				this.headerMap.put(k, row[k]);
          			}
          		}else{
          			
          			//Column 0 is the time
          			Integer Id = Integer.parseInt(row[0]);
          			
          			//Empty additional parameters
          			Map<String, String> extraParams = new HashMap<String,String>();
          			
          			//For each additional column we will create an Import Point
          			for(int i=1; i<row.length; i++){
          				String identifier = headerMap.get(i); //Get the identifier from our header map
          				double value = Double.parseDouble(row*); //Create the value
          				NumericImportPoint point = new NumericImportPoint(identifier, value, Id, extraParams);
          				this.parsedPoints.add(point);
          			}
          		}
          	}
          }
          

          0_1593713145809_d3c57461-9762-4b63-8144-943d22f41b85-image.png

          So here you can see data points for only the last row.

          1 Reply Last reply Reply Quote 0
          • MattFoxM
            MattFox
            last edited by

            Have you gone to data point details and looked at the points in detail?

            Do not follow where the path may lead; go instead where there is no path.
            And leave a trail - Muriel Strode

            J 1 Reply Last reply Reply Quote 0
            • J
              Jerrod Tanner @MattFox
              last edited by

              @mattfox thanks so much for the help, I made a silly mistake but I am glad it made me more familiar with Mango. I ended up crafting quite the nice CSV importer with some bells and whistles.

              1 Reply Last reply Reply Quote 0
              • MattFoxM
                MattFox
                last edited by

                Nicely done, if you're willing to share I'm confident others can definitely learn from your approach!

                Fox

                Do not follow where the path may lead; go instead where there is no path.
                And leave a trail - Muriel Strode

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post