public static int[] GetColumnIndexes(string[] columnNames, string[] requiredColumns)
        {
            int[] requiredColumnIndexes = new int[requiredColumns.Length];
            for (int i = 0; i < requiredColumns.Length; i++)
            {
                requiredColumnIndexes[i] = CsvInfo.GetColumnIndex(columnNames, requiredColumns[i]);
            }

            return(requiredColumnIndexes);
        }
        public string[] Read(string filePath, string[] requiredColumns)
        {
            #region Variables
            List <string> fileData              = new List <string>();
            string[]      columnNames           = CsvInfo.GetColumns(filePath);
            int[]         requiredColumnIndexes = CsvInfo.GetColumnIndexes(columnNames, requiredColumns);
            #endregion

            using (StreamReader csvReader = File.OpenText(filePath))
            {
                var line = "";
                while ((line = csvReader.ReadLine()) != null)
                {
                    ProcessLine(fileData, requiredColumnIndexes, line);
                }
            }

            return(fileData.ToArray());
        }
        public static bool CheckFormat(string path, IEnumerable <string> columnNames)
        {
            var columnsInFile = CsvInfo.GetColumns(path);

            if (columnsInFile == null)
            {
                return(false);
            }
            var noOfColumns = columnsInFile.Length;

            foreach (var column in columnNames)
            {
                if (!Array.Exists(columnsInFile, element => element.Contains(column, StringComparison.OrdinalIgnoreCase)))
                {
                    return(false);
                }
            }
            ICsvFileReader reader = new CsvFileReader();
            var            lines  = reader.Read(path);

            return(IsNoOfColumnsSameInEachRow(lines, noOfColumns));
        }