Example #1
0
        public void parseCSV(string path, bool headerOnly, int numberOfHeaderLines)
        {
            try
            {
                using (StreamReader readFile = new StreamReader(path))
                {
                    csvFileHeader = new CSVFileHeader();
                    csvFileHeader.parseHeader(readFile, numberOfHeaderLines);

                    if (!headerOnly)
                    {
                        csvFileData = new CSVFileData();
                        csvFileData.parseData(readFile);
                    }
                }
            }
            catch (CSVFileException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new CSVFileException(e);
                //                    MessageBox.Show(e.Message);
            }
        }
Example #2
0
        public void startParsingCSVData(string path, int numberOfHeaderLines, int numberOfLinesToSkip)
        {
            int lNumberOfOpenAttempts = 0;

            while (true)
            {
                try
                {
                    m_ReadFile    = new StreamReader(path);
                    csvFileHeader = new CSVFileHeader();
                    if (numberOfHeaderLines > 0)
                    {
                        csvFileHeader.parseHeader(m_ReadFile, numberOfHeaderLines);
                    }

                    for (int i = 0; i < numberOfLinesToSkip; i++)
                    {
                        m_ReadFile.ReadLine();
                    }

                    ConsoleLogger.logMessage("lNumberOfOpenAttempts = " + lNumberOfOpenAttempts);
                    break;
                }
                catch (CSVFileException e)
                {
                    lNumberOfOpenAttempts++;
                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception e)
                {
                    lNumberOfOpenAttempts++;
                    System.Threading.Thread.Sleep(1000);
                    //                    MessageBox.Show(e.Message);
                }
                finally
                {
                    if (lNumberOfOpenAttempts > ProjectCommon.ProjectConstants.NUMBER_OPEN_FILE_ATTEMPTS)
                    {
                        throw new CSVFileException("Could not open file " + path);
                    }
                }
            }
        }
        public void startParsingCSVData(string path, int numberOfHeaderLines, int numberOfLinesToSkip)
        {
            int lNumberOfOpenAttempts = 0;
            while (true)
            {
                try
                {
                    m_ReadFile = new StreamReader(path);
                    csvFileHeader = new CSVFileHeader();
                    if (numberOfHeaderLines > 0)
                        csvFileHeader.parseHeader(m_ReadFile, numberOfHeaderLines);

                    for (int i = 0; i < numberOfLinesToSkip; i++)
                        m_ReadFile.ReadLine();

                    ConsoleLogger.logMessage("lNumberOfOpenAttempts = " + lNumberOfOpenAttempts);
                    break;

                }
                catch (CSVFileException e)
                {
                    lNumberOfOpenAttempts++;
                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception e)
                {
                    lNumberOfOpenAttempts++;
                    System.Threading.Thread.Sleep(1000);
                    //                    MessageBox.Show(e.Message);
                }
                finally
                {
                    if (lNumberOfOpenAttempts > ProjectCommon.ProjectConstants.NUMBER_OPEN_FILE_ATTEMPTS)
                        throw new CSVFileException("Could not open file " + path);
                }
            }
        }
        public void parseCSV(string path,bool headerOnly,int numberOfHeaderLines)
        {
            try
            {
                using (StreamReader readFile = new StreamReader(path))
                {
                    csvFileHeader = new CSVFileHeader();
                    csvFileHeader.parseHeader(readFile, numberOfHeaderLines);

                    if (!headerOnly)
                    {
                        csvFileData = new CSVFileData();
                        csvFileData.parseData(readFile);
                    }

                }
            }
            catch (CSVFileException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new CSVFileException(e);
                //                    MessageBox.Show(e.Message);
            }
        }