private LASDataRow ParseCSVLine(int columnOffset, string line, int columnCount, out int errorCode, double nullValue) { // Parse a line such as this: char[] splitArray = new char[3]; // set up the delimiting characters splitArray[0] = '\t'; splitArray[1] = ','; errorCode = 0; List<string> dataItemList = new List<string>(); string[] items = line.Split(splitArray, StringSplitOptions.None); // ignore index 0, as it is ~S LASDataRow ldr = new LASDataRow(columnCount); if (items.Length - columnOffset != columnCount) { // not enough items int xxx = 0; } try { string strDeptth = items[columnOffset]; try { ldr.depth = Convert.ToDouble(strDeptth.Trim()); } catch (Exception ex) { errorCode = LASErrorCodes.CSV_DEPTH_FIELD_PARSE_ERROR; } if (errorCode == 0) { for (int i = columnOffset + 1; i < items.Length; i++) { double ii = nullValue; if (items[i].Trim().Length > 0) { try { ii = Convert.ToDouble(items[i].Trim()); } catch (Exception ex) { }; } ldr.rowData[i - (columnOffset + 1)] = ii; } } } catch (IndexOutOfRangeException) { errorCode = LASErrorCodes.CSV_PARSE_INDEERROR; } catch (Exception ex) { errorCode = LASErrorCodes.CSV_PARSE_ERROR; ; } return ldr; }
private LASDataRow ParseCSVLineFIXED(string line, int columnCount, double nullValue) { // Parse a line such as this: char[] splitArray = new char[3]; // set up the delimiting characters splitArray[0] = '\t'; splitArray[1] = ','; List<string> dataItemList = new List<string>(); string[] items = line.Split(splitArray, StringSplitOptions.None); // ignore index 0, as it is ~S LASDataRow ldr = new LASDataRow(8); int columnOffset = 5; //HOLEID, PROJECTCODE,DEPTHSTEP, RUN, GEOPHYSGID, DEPTH , CALLMM, GAMMAP, DESSGC, DELSGC, RESHOM, NESSSN, SO2FUF, UCSMPA string depth = items[columnOffset + 0]; string CALLMM = items[columnOffset + 1]; string GAMMAP = items[columnOffset + 2]; string DESSGC = items[columnOffset + 3]; string DELSGC = items[columnOffset + 4]; string RESHOM = items[columnOffset + 5]; string NESSSN = items[columnOffset + 6]; string SO2FUF = items[columnOffset + 7]; string UCSMPA = items[columnOffset + 8]; string[] newItems = { /*depth,*/ CALLMM, GAMMAP, DESSGC, DELSGC, RESHOM, NESSSN, SO2FUF, UCSMPA }; for (int i = 0; i < newItems.Length; i++) { double ii = nullValue; if (newItems[i].Trim().Length > 0) { try { ii = Convert.ToDouble(newItems[i].Trim()); } catch (Exception ex) { }; } ldr.rowData[i] = ii; } ldr.depth = Convert.ToDouble(depth.Trim()); return ldr; }
private LASDataRow ParseDataLine(string line, int columnCount, out int errorCode, double nullValue) { // Parse a line such as this: //~A DEPT[M] Gamma[cp Current[ R16[Ohm- R32[Ohm- R64[Ohm- R8[Ohm-m SP[mV] SPR[Ohm] Density[ Caliper[ Full Wav char[] splitArray = new char[3]; errorCode = 0; // set up the delimiting characters splitArray[0] = '\t'; splitArray[1] = ','; splitArray[2] = ' '; List<string> dataItemList = new List<string>(); string[] items = line.Split(splitArray, StringSplitOptions.RemoveEmptyEntries); //if (items.Length < columnCount) { // errorCode = LASErrorCodes.INSUFFICIENT_DATA_COLUMNS; //} // ignore index 0, as it is ~S LASDataRow ldr = new LASDataRow(columnCount); double dt = Convert.ToDouble(items[0].Trim()); ldr.depth = dt; for (int i = 1; i < items.Length; i++) { double ii = nullValue; Double.TryParse(items[i].Trim(), out ii); //try { // ii = Convert.ToDouble(items[i].Trim()); } //catch (Exception ex) { //} // first item shoudl always be depth ldr.rowData[i-1] = ii; } return ldr; }