Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to avoid teh Filestream.position from reading whitespace

Status
Not open for further replies.

Programming2007

Programmer
Nov 10, 2006
24
US
Hi I have a huge file with numbers and white space. Each of the numbers in a specified position represents a field. The problem is that when I read the numbers at the specified position it takes whitespace into account. How do I avoid this? Below is my code:

Files = Directory.GetFiles("C:\\QuestLD", "*")
For Each File In Files
Dim fs As New FileStream(File, FileMode.Open, FileAccess.Read)
Dim sw As New StreamReader(fs)
rawFileData = sw.ReadToEnd()
rawFileData.Trim()

'410 digits in tuple
tuple = rawFileData.Substring(startIndex + startIndex, 410)
'tuple = rawFileData.Substring(startIndex, 20)

fs.Position = 67
ORIG_TIME = tuple.Substring(startIndex + 67, 6)

fs.Position = 116
ANI = tuple.Substring(startIndex + 116, 15)


fs.Position = 101
CALLED_NO = tuple.Substring(startIndex + 101, 15)


fs.Position = 51
ORIG_DT = tuple.Substring(startIndex + 51, 8)



sql_insert(ORIG_TIME, ANI, CALLED_NO, ORIG_DT)
startIndex = startIndex + 410
'separate line records by fields by groups in fields

Next File

End Sub
 
If I understand correctly, the substrings are returning both the required value and whitespace (either or both before or after the value).

If that is the case then, for example:

[tt]ORIG_TIME = tuple.Substring(startIndex + 67, 6).Trim[/tt]


should do what you need.


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top