Creating Tab Delimited text file

Anyone has any idea how to create a tab delimited file??

i know how to create csv file. i simply create a query with the information i need and then looping through the query and add in " and , for CSV file.

Simply use a CHR(9), tab character, instead of the comma to separate the fields when writing to the file.

Do i need to have " for the values??? what about a field with multiple line and carriage return

If your data is in an array, use join to create each line:

dim aLine as string = join( lineDataArr, Chr( 9 ) )

But if you have fields that may contain EOL characters or even tabs, a tab-delimited format might not be the best choice for you. It depends on why you want to create this file, and where it will be used.

i don’t think the data will have tab but definitely carriage return like paragraph in biography of an artist.

Is EOL the same as carriage return or line feed?

Yes, EOL can be a return, linefeed, or a return-linefeed combination (Windows).

What will you (or your users) be doing with this file once it’s created?

my idea is probably replace the CRLF with “
” and get the user to open the text file and replace “
” with CRLF in Excel.

I just checked, and Excel already has a means of doing this. Surround each field with double-quotes and the EOL characters won’t matter. If the field already has double-quotes in it, double them up (just like when you do it in a Xojo string). So if your field is:

this"a"
that

What you can store is:

"this""a""
that"

Excel will properly translate that.

[quote=25279:@Richard Duke]Anyone has any idea how to create a tab delimited file??

i know how to create csv file. i simply create a query with the information i need and then looping through the query and add in " and , for CSV file.[/quote]

Actually that’s kind of true - but not really
You need to handle quotes in field values specially & also newlines if you have them

Kem, do i need to put double quote on integer, date or double value then?

I think you can mix quoted and unquoted fields.