I need urgent help reading from a textfile with vbcrlf for the row delimiter (end of line), however, the vbcrlf can sometimes be in the data within the row. This causes the reader to think it has encountered a new row even though it is still has now finished reading/parsing the full row.
I am using a pipe sysmbol "|" as a column delimiter. There are 51 columns in each row.
The simplest would be is to use a combo delimiter of vbcrlf and "|" to see if it has really reached the end of the row (this does not seem possible to do).
Another thing is to make sure that the 51 columns are parsed for each row/line even if the vbcrlf is encountered before the row is read/parsed to the end. However, I do not know how to do this. Concrete code example needed...
I need urgent help on this. Please see my code for details.
Dim ZipToUnpack As String = fullzippath
Dim TargetDir As String = Server.MapPath("uploads/")
Dim ez As ZipEntry
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
' based on entry name, size, date, etc.
For Each ez In zip1
' Once extracted, let us know
dvResults.InnerHtml &= "<br />File <b>" & ez.FileName & "</b> has been extracted and uploaded." ' & TargetDir
' Open the file, using a streamreader
Dim objSR As StreamReader = File.OpenText(TargetDir & ez.FileName)
' Read the file's contents into a variable
Dim contents As String = objSR.ReadToEnd()
' Start: write Biodata CROSSREF to table
If ez.FileName.Contains("Cross") Then
' the array of rows
Dim arrRows() As String = contents.Split(vbCrLf) 'contents.Split("|" + vbCrLf)
Dim arrCells() As String
' Loop through its contents
For Each a As Object In arrRows
Dim tbl As New Object
tbl = New tblBiodata_Cross_Reference_TEMP
dcMeheret.ExecuteCommand("Truncate table tblBiodata_Cross_Reference_TEMP")
' If a line doesn't have |, then skip it
If a.Contains("GUID") Then Continue For
' Split each row into the 3 columns
arrCells = a.Split("|")
' Add each cell into the linq table row
.Row = arrCells(0)
.Case_GUIDFrom = New Guid(arrCells(1))
.FullCaseNoFrom = arrCells(2)
' End: write Biodata CROSSREF to table
' *** End: write biotable to respective tables. ***
' Close the streamreader
' Save changes