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.
Is it possible to read several csv documents by scripting?
-
I meet trouble when attempting to read elements in local csv document by scripting. I know there is another channel to import csv document. But I have to use scripting, because I need to import csv document that is automatically generated by server in real-time. Any help or advice would be appreciated.
-
Hi RayZhang,
I am not certain I fully understand what you're trying to achieve, but...
The data file data source can do almost anything. You have to implement a Java class for the CSV (or binary file, excel sheet, excel workbook, and xml), and then you point the data source at a file or directory to poll using the class you've written. A recent addition to the data file data source was the opportunity to supply a polling class as well, which you can do most anything with, but its thought is the files may required FTP'ing or some such process of acquisition. The little blue (?) has some basic examples of these classes.
As for using scripting, it's probably only possible to read the file by using Java directly. Something like...
var pathToCsv = "/path/to/csv.csv" var csvReader = new java.io.BufferedReader(new java.io.FileReader(new java.io.File(pathToCsv))); try { var row; while((row = csvReader.readLine()) !== null) { var data = row.replace(/[\r\n]/g, "").split(","); print(data); } } finally { csvReader.close(); }
-
Thanks a lot, phil. It works preliminary.
-
Certainly! I did just edit it though... needed to be more caring with system resources than I was.