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.
CSV as data points
-
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?
-
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
-
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); } } } }
So here you can see data points for only the last row.
-
Have you gone to data point details and looked at the points in detail?
-
@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.
-
Nicely done, if you're willing to share I'm confident others can definitely learn from your approach!
Fox