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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delimiter?

Status
Not open for further replies.

wallywojo

Programmer
Aug 30, 1999
36
US
Is there a command or function that tells you what the delimiter character is in a text file?
 
No you have to know it going in.<br>
You can open the file in Notepad or Wordpad and take a look at it.<br>
<br>

 
you can count the chars and find the highest number of accurences. if it is a long file this will work very well.<br>
then assume that the highest number is the delimiter.<br>
<br>
it will not be that accurate for small files. but there is always a way to do what you are looking to do.<br>
<br>
if you do the search in ascii then you can find tab and other chars also.<br>
<br>
if you would like more info email me.<br>
<A HREF="mailto:trbrenke@yahoo.com">trbrenke@yahoo.com</A>
 
wallyw -<br>
<br>
You can do occurrance counting like trbrenke suggested, but you're likely to choose the wrong character (like, picking &lt;space&gt; instead of &lt;tab&gt;).<br>
<br>
I'm afraid this is a case of &quot;You just gotta know&quot;.<br>
<br>
Chip H.<br>

 
Dim delimiter As String<br>
Dim sql_statement As String<br>
<br>
If delimiter = &quot;&lt;space&gt;&quot; Then delimiter = &quot; &quot;<br>
If delimiter = &quot;&lt;tab&gt;&quot; Then delimiter = vbTab<br>
<br>
Do While Not EOF(fnum)<br>
' Read a text line.<br>
Line Input # fnum, text_line<br>
<br>
Do While Len(text_line) &gt; 0<br>
pos = InStr(text_line, delimiter)<br>
If pos = 0 Then<br>
' Add the rest of the line.<br>
sql_statement = sql_statement & _<br>
&quot;'&quot; & text_line & &quot;', &quot;<br>
text_line = &quot;&quot;<br>
Else<br>
<br>
sql_statement = sql_statement & _<br>
&quot;'&quot; & Left$(text_line, pos - 1) & _<br>
&quot;', &quot;<br>
text_line = Mid$(text_line, pos + Len(delimiter))<br>
End If<br>
End If<br>
Loop<br>
<br>
' Remove the last comma.<br>
sql_statement = Left$(sql_statement, Len(sql_statement) - 2) &<br>
&quot;)&quot;<br>
<br>
List1.AddItem sql_statement<br>
<br>
Loop<br>
<br>
Close fnum<br>
<br>
it's a sample !<br>
<br>
Eric De Decker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top