|
-
Aug 7th, 2007, 10:03 AM
#1
Thread Starter
Fanatic Member
[2005] Importing from Excel
Hello all,
I first have a .LAS file that is converted to a .CSV file. The csv file will either have 3 or 4 columns but with the import, we just need 3 columns instead of the 4th. Currently, the code below doesn't read the skipcolumn line; it will read if it is 0 or empty.
For example you will have columns 1, 2, 3, 4 and column 2 is the one you don't want to import, how would i skip that column and the values from the array?
PLEASE HELP!!!!
Code:
'This loops through splitout to remove all the empty/null values from the array
'results holds all the values that aren't null from splitout
For z As Integer = 0 To splitout.GetUpperBound(0)
ten = splitout.GetValue(z)
If Not findtxt = splitout.GetValue(z) Then
value = splitout.GetValue(z)
results.Add(value.ToString)
End If
Next
'Checks for the first line of the array for the null value which is -999.0000
If results(0).Equals("-999.0000") Then
results.RemoveRange(0, 3)
End If
cmd.Connection = gConn
gConn.Open()
trans = gConn.BeginTransaction()
cmd.Transaction = trans
count = results.Count - 1
currentPosition = 0
' Read the entire array
If varType = "LogCurve" Then
For i = 0 To ((results.Count) / 3) - 1 ' The three reps the # of columns
If chkApi.Checked = True Then
varApi = results(x + (nbxApi.Value - 1))
Else
varApi = txtApi.Text
End If
If nbxDepth.Value = 0D Then
varDepth = "-999.0000"
Else
If results(x + (nbxDepth.Value - 1)) = "" Then
varDepth = "-999.0000"
Else
varDepth = results(currentPosition)
End If
End If
currentPosition = currentPosition + 1
If nbxSPC.Value = 0D Then
varSPC = "-999.0000"
Else
If results(x + (nbxSPC.Value - 1)) = "" Then
varSPC = "-999.0000"
Else
varSPC = results(currentPosition)
End If
End If
currentPosition = currentPosition + 1
If nbxVSH.Value = 0D Then
varVSH = "-999.0000"
Else
If results(x + (nbxVSH.Value - 1)) = "" Then
varVSH = "-999.0000"
Else
varVSH = results(currentPosition)
End If
End If
If currentPosition.ToString = count.ToString Then
Me.InsertDB()
Else
Me.InsertDB()
varCount = varCount + 1
currentPosition = currentPosition + 1
End If
Next
Using Visual Studio 2008
Please mark your thread RESOLVED if you no longer need help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|