Best Delimiter for CSV reader

1,049 views
Skip to first unread message

Bill

unread,
Jan 15, 2010, 2:10:26 PM1/15/10
to CSVChat
Bruce,

I'm reading a text file that is created from a mainframe and I need a
suggestion for a deliniter other than the comma. I've gone through
the groups postings and seen just about every option. I don't have
any control over the text output and get commas in numbers and also
text field. In your opinion what would you feel is the next best
solution that the CSV reader can handle? Double quotes? Square
Brackets? Other? I have a bit of control over the delimiter that they
use in this situation.

Thanks,

shriop

unread,
Jan 15, 2010, 2:52:14 PM1/15/10
to CSVChat
Well the CSV spec handles all the text issues that you're describing
by using text qualifiers and escape sequences in addition to just the
comma, so none of that requires you to switch to another delimiter
other than comma. Now I do understand the annoyances trying to get the
mainframe to write data using the escape sequences so I'll go back to
your question. I would suggest simply using tab delimited files. I see
fewer issues daily using tab delimited files than other formats like
pipe delimited and it's fairly well recognized. And to read a tab
delimited file using CsvReader, you just set Settings.Delimiter to tab
and Settings.UseTextQualifier to false.

Bruce Dunwiddie

Bill

unread,
Feb 10, 2010, 11:47:16 AM2/10/10
to CSVChat
This may be a dumb question but how do I set the delimiter to tab?

I tried

System.Text.Encoding.Default= tab
and also

Dim csvData As New DataStreams.Csv.CsvReader(openFile.FileName, TAB,
System.Text.Encoding.Default)
but it's looking for the Char.. Do I set it to the Char value of 9?
Thanks

On Jan 15, 2:52 pm, shriop <shr...@hotmail.com> wrote:
> Well the CSV spec handles all the text issues that you're describing
> by using text qualifiers and escape sequences in addition to just the
> comma, so none of that requires you to switch to another delimiter
> other than comma. Now I do understand the annoyances trying to get the
> mainframe to write data using the escape sequences so I'll go back to
> your question. I would suggest simply using tab delimited files. I see
> fewer issues daily using tab delimited files than other formats like
> pipe delimited and it's fairly well recognized. And to read a tab
> delimited file using CsvReader, you just setSettings.Delimiter to tab

> andSettings.UseTextQualifier to false.


>
> Bruce Dunwiddie
>
> On Jan 15, 1:10 pm, Bill <morgenw...@gmail.com> wrote:
>
>
>
> > Bruce,
>
> > I'm reading a text file that is created from a mainframe and I need a
> > suggestion for a deliniter other than the comma.  I've gone through
> > the groups postings and seen just about every option.  I don't have
> > any control over the text output and get commas in numbers and also
> > text field.  In your opinion what would you feel is the next best
> > solution that the CSV reader can handle? Double quotes? Square
> > Brackets? Other? I have a bit of control over the delimiter that they
> > use in this situation.
>

> > Thanks,- Hide quoted text -
>
> - Show quoted text -

shriop

unread,
Feb 10, 2010, 12:00:57 PM2/10/10
to CSVChat
in VB.Net, the simplest way would probably be

csvData.Settings.Delimiter = vbTab

if you needed to set it to some other typeable character, you can use
the syntax

csvData.Settings.Delimiter = "|"c

although it looks like VB.Net will do the conversion for you if you
leave out the c

csvData.Settings.Delimiter = "|"

or yes, if you know the ascii number, you should be able to use this
syntax

csvData.Settings.Delimiter = Convert.ToChar(9)

It's even possible that there's some other simpler syntax for
converting a number to a char in VB.Net using some odd suffix, but I
don't know it.

Bruce Dunwiddie

> > - Show quoted text -- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages