• 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

    Is it possible to read several csv documents by scripting?

    Scripting general Discussion
    2
    4
    1.6k
    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.
    • R
      RayZhang
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by phildunlap

        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();
        }
        
        1 Reply Last reply Reply Quote 0
        • R
          RayZhang
          last edited by

          Thanks a lot, phil. It works preliminary.

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Certainly! I did just edit it though... needed to be more caring with system resources than I was.

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