From: Volker Jordan on
"goshute" wrote:

> >
> > Its the same. Manually the 0 are converted to numbers.
>
> No, You can not import a .csv file with all columns defined as text
> because Excel is trying to be helpful and defining what looks like
> numbers as numbers.
> I know of two ways to handle this.
> Change the .csv to .txt
> Insert a single quote ' as the first character in these fields forcing
> Excel to handle as text.
>

The problem is, that I have to read csv data, that is not generated by
myself. So renaming and inserting a quote in not an option. I wonder, why
there is no hint in the documentation, that FieldInfo does not work with
files ending with .csv.

Volker
From: goshute on
On Jan 7, 3:46 am, Volker Jordan
<VolkerJor...(a)discussions.microsoft.com> wrote:
> "goshute" wrote:
>
> > > Its the same. Manually the 0 are converted to numbers.
>
> > No,  You can not import a .csv file with all columns defined as text
> > because Excel is trying to be helpful and defining what looks like
> > numbers as numbers.
> > I know of two ways to handle this.
> > Change the .csv to .txt
> > Insert a single quote ' as the first character in these fields forcing
> > Excel to handle as text.
>
> The problem is, that I have to read csv data, that is not generated by
> myself. So renaming and inserting a quote in not an option. I wonder, why
> there is no hint in the documentation, that FieldInfo does not work with
> files ending with .csv.
>
> Volker

Sorry Volker, I was not clear in my last post and I was out for a few
days. I learned how to handle these files after working with them for
years. You only have to do one of the two suggestions. Adding single
tick mark to the beginning of the field will force Excel to handle
that value as text when it opens the file. If you change the
extension to .txt, Excel will give you the import wizard where you can
select text for the column.
I normally handle these kinds of issues with VBA. I look in the
directory and rename the file with a .txt extension. Afterall
the .csv file is nothing more than a text file with the .csv
extension. Then when I open the file, either manually or with VBA, I
can define the data formats. There are lots of examples on this site
to read a directory and rename a file but I can post examples if it
helps.
Goshute