• 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

    Solved Writing a custom CSV importer

    User help
    2
    3
    876
    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.
    • cbyrneC
      cbyrne
      last edited by

      I want to write a custom CSV importer by extending the AbstractCSVDataSource and overriding the appropriate method:

      @Override
          public void importRow(String[] row, int rowNum)
      

      My issue is that I don't know what String[] row will look like. There's obviously a parser that provides this but I'm not sure where to find it or whether it changes.

      Can anyone point me in the right direction? For now I'll just hack in a System.out.println() and go from what I see there.

      Thanks,
      C

      Software Developer for GLAS Energy Technology, Ireland

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

        Hi cbyrne,

        Unfortunately the Data File Data Source is in one of our private repositories, so I cannot link you to the source code directly.

        The parser being used is a au.com.bytecode.opencsv.CSVReader.CSVReader which is getting its separator, quote character, and escape character from the AbstractCSVDataSource class, unless you override the methods providing these in your implementing class, i.e.

        @Override
        public char getSeparatorCharacter() {
            return ','; //split on commas
        }
        
        @Override
        public char getQuoteCharacter() {
            return '"'; //unless the commas are in quote pairs
        }
        
        @Override
        public char getEscapeCharacter() {
            return '\\';
        }
        

        It will pass each line that it reads as it reads and parses it to the import row function.

        1 Reply Last reply Reply Quote 0
        • cbyrneC
          cbyrne
          last edited by

          Perfect, thanks for your help @phildunlap . Much appreciated!

          Software Developer for GLAS Energy Technology, Ireland

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