.. include:: ../../toolkit-substitutions

.. oe:namespace:: OESaiph


.. meta::
   :keywords: OECSVFileConverter, CSVFileConverter


.. _OESaiph_OECSVFileConverter:

.. oe:class:: OECSVFileConverter

   .. attention::

      |PRELIMINARY-API|

   .. oe:api::

      class OECSVFileConverter

   The :ref:`OECSVFileConverter <OESaiph_OECSVFileConverter>` class extracts data from CSV and TSV
   files into :ref:`OERecord <OEDataFlow_OERecord>`. Custom data extraction based on delimiter type
   and OEField inclusion can be set up through the :ref:`OECSVConversionOptions <OESaiph_OECSVConversionOptions>`. 
   
   .. oe:method:: Constructors

      .. oe:language:: c++ java csharp

         .. oe:api::

            OECSVFileConverter()
            OECSVFileConverter(const OECSVFileConverter &)

      .. oe:language:: python

         .. oe:api:: python

            OECSVFileConverter() -> OECSVFileConverter
            OECSVFileConverter(arg2: OECSVFileConverter) -> OECSVFileConverter

   .. oe:method:: Open

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Open(const std::string& path,
                      const std::string& displayName = std::string()) override
            bool Open(const std::string& path,
                      const OECSVConversionOptions& options,
                      const std::string& displayName = std::string())

      .. oe:language:: python

         .. oe:api:: python

            Open(path: str, displayName: str = str()) -> bool
            Open(path: str, options: OECSVConversionOptions,
                 displayName: str = str()) -> bool

      Returns a boolean based on whether the file can be opened.
      :ref:`OECSVConversionOptions <OESaiph_OECSVConversionOptions>`
      is set at open.
      
   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OECSVFileConverter &operator=(const OECSVFileConverter &)

      Assignment operator.


   .. oe:method:: Close

      .. oe:language:: c++ java csharp

         .. oe:api::

            void Close()

      .. oe:language:: python

         .. oe:api:: python

            Close() -> None

      Closes the stream.

   .. oe:method:: GetNextRecord

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned int GetNextRecord(OEDataFlow::OEMolRecord& record) override

      .. oe:language:: python

         .. oe:api:: python

            GetNextRecord(record: OEMolRecord) -> int

      Steps through each row of the file adding to the :ref:`OEMolRecord <OEDataFlow_OEMolRecord>`
      passed into the function. The function returns constants based on each pass.
      Return codes: ``SaiphReturnCode::Success``, ``SaiphReturnCode::Fail``, ``SaiphReturnCode::EndOfFile``

   .. oe:method:: GetProgress

      .. oe:language:: c++ java csharp

         .. oe:api::

            float GetProgress()

      .. oe:language:: python

         .. oe:api:: python

            GetProgress() -> float

      Returns the percentage of the file that has been traversed.

