Read & Write Tab seprated file

Hi, I need code to read Tab seprated text file, I could read coma seprated file, but I need to know how to read tab seprated text file.

Please help.

Regards,

Lingaraje…

Subject: Read & Write Tab seprated file

We’ve just had to do the same thing. I presume for comma-delimited etc you’re passing the specific character in lotusscript as the delimiter, e.g. “,”. The way to manage it is to set the delimiter as the character code, Chr$(9) for a tab.

This seems to work fine on Windows in UK, and our import runs on a known server, so we would not have any issues. But you may need to bear in mind that the character code may be different for other operating systems/language settings.

Subject: RE: Read & Write Tab seprated file

Thanks Paul, If you have the reference code can you please share it to me so that it will be helpful for me.

Regards,

Lingaraje…

Subject: RE: Read & Write Tab seprated file

Sure, no problems.

We use a config document to hold what the delimiter being used is, and just vary the code slightly if the delimiter is numeric (I’ve not come across anyone using a number as a delimiter, and wouldn’t suggest it!).

I’ve simplified the code a bit, removing some checks we have for the UBound of the array and error trapping, but the essentials should help you. Import is:

Dim delim As String

Do Until Eof(inFilenumber)

Line Input #inFilenumber, stInputstring

If Isnumeric (configDoc.AsciiDelim(0)) Then

	delim = Chr$(configDoc.AsciiDelim(0))

Else

	delim = configDoc.AsciiDelim(0)

End If

stInputrecord = Split(stInputstring, delim)

Set ExchangeRateDoc = New NotesDocument (dbThis)

ExchangeRateDoc.Form = "Currency Exchange Rate"

ExchangeRateDoc.CoNumber = Fulltrim(stInputRecord(0))

ExchangeRateDoc.SourceCurrency = Fulltrim(stInputRecord(1))

ExchangeRateDoc.TargetCurrency = Fulltrim(stInputRecord(2))

ExchangeRateDoc.Rate = Fulltrim(stInputRecord(3))

ExchangeRateDoc.MDFactor = Fulltrim(stInputRecord(4))

Call ExchangeRateDoc.Save (False, False)

Loop

For export, virtually the same, when writing add in the relevant delimiter:

If x = 0 Then

	outputString = fieldVal

Else

	outputString = outputString + delim + fieldVal

End If

Print #FileNum, outputString