Exemplo n.º 1
0
        private void LoadGeophysiscsTextDataForPreview(string inputFilename)
        {
            IOResults ares = new IOResults();

            List<ColumnMetaInfo> dbFields = GetGeophysicsFieldsFromNKD();
            // talk to the database to get the column names 

            ImportDataPreview.SetMandatoryMappingColumns(dbFields);
            ImportDataPreview.SetPreviewType("GEOPHYISCS");

            bool firstLineIsHeader = true;

            if (inputFilename.ToLower().EndsWith("las"))
            {
                LASFileReader lfr = new LASFileReader();
                int errCode = 0;
                LASFile fl = lfr.ReadLASFile(inputFilename, 0, out errCode);

                List<RawDataRow> dt = new List<RawDataRow>();
                RawDataRow rdh = new RawDataRow();
                rdh.dataItems = new List<string>();
                rdh.dataItems.Add("Depth");
                foreach (string ss in fl.columnHeaders)
                {
                    rdh.dataItems.Add(ss);
                }

                dt.Add(rdh);
                foreach (LASDataRow ldr in fl.dataRows)
                {
                    RawDataRow rd = new RawDataRow();
                    rd.dataItems.Add("" + ldr.depth);
                    foreach (double d in ldr.rowData)
                    {
                        rd.dataItems.Add("" + d);
                    }
                    dt.Add(rd);
                }

                ImportDataPreview.ResetTable(dt, true);

            }
            else
            {
                var rawFileReader = new RawFileReader(',');
                List<RawDataRow> dt = rawFileReader.LoadRawDataForPreview(inputFilename, ares);
                ImportDataPreview.ResetTable(dt, firstLineIsHeader);

            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="allLines"></param>
        /// <param name="ares"></param>
        /// <returns></returns>
        private List<RawDataRow> ParseDataLines(List<string> allLines, IOResults ares, char delimeter)
        {
            List<RawDataRow> dt = new List<RawDataRow>();

         


            char[] splitArray = new char[3];
            // set up the delimiting characters
            splitArray[0] = delimeter;
            
            int fileLineNumber = 1;
            foreach (string ln in allLines)
            {
                try
                {

                    string[] items = splitQuoted(ln, delimeter);
                   // string[] items = ln.Split(splitArray, StringSplitOptions.None);
                    RawDataRow rdr = new RawDataRow();
                    rdr.dataItems = new List<string>(items);
                    dt.Add(rdr);
                }
                catch (Exception ex)
                {
                    // error parsing the line, or casting the objects
                    ares.errorMessage += ex.ToString();
                    
                }
                fileLineNumber++;
            }
            return dt;
        }