Class CSVReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class CSVReader
    extends java.lang.Object
    implements java.io.Closeable
    Utility class for reading from CSV files, using FastCSV.
    • Constructor Summary

      Constructors 
      Constructor Description
      CSVReader​(java.lang.String path)
      Construct a new CSV file reader, using a comma (as the C in CSV implies) as the field separator.
      CSVReader​(java.lang.String path, char fieldSeparator)
      Construct a new CSV file reader, using a specific field separator character.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      void streamRows​(AssetGenerator assetForRow, int batchSize)
      Parallel-read the CSV file into batched asset updates against Atlan.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CSVReader

        public CSVReader​(java.lang.String path)
                  throws java.io.IOException
        Construct a new CSV file reader, using a comma (as the C in CSV implies) as the field separator.
        Parameters:
        path - location and filename of the CSV file to read
        Throws:
        java.io.IOException - on any errors accessing or reading from the file
      • CSVReader

        public CSVReader​(java.lang.String path,
                         char fieldSeparator)
                  throws java.io.IOException
        Construct a new CSV file reader, using a specific field separator character.
        Parameters:
        path - location and filename of the CSV file to read
        Throws:
        java.io.IOException - on any errors accessing or reading from the file
    • Method Detail

      • streamRows

        public void streamRows​(AssetGenerator assetForRow,
                               int batchSize)
        Parallel-read the CSV file into batched asset updates against Atlan. Note: this requires the input CSV file to be fully parallel-loadable without any conflicts. That means: every row is a unique asset, no two rows update any relationship attribute that points at the same related asset (such as an assigned term).
        Parameters:
        assetForRow - a function (could just be a lambda) that turns a list of string values (from the row) into an Asset
        batchSize - maximum number of Assets to bulk-save in Atlan per API request
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException