Reading CSV Files in XL-VBA 
Author Message
 Reading CSV Files in XL-VBA

Hello,

I wonder if anyone could help me?

For several days I have been trying to write a routine in VBA (Excel97) that
will read a CSV file created by another program.  The trouble is, the CSV
file sometimes has double-quotes and / or commas within the field data!

I have been going round and round in circles and I would be grateful if
anyone could advise me how to solve this problem.

Thanks in anticipation,

Brian



Thu, 27 Nov 2003 03:13:00 GMT  
 Reading CSV Files in XL-VBA
Lars,

Thanks for the response.  However, the original CSV files (over which I have
no control, as they came from other people) have double-quotes as text
qualifiers and commas as field separators!  In addition, they still have
instances of double-quotes and / or commas within the field data.  It sounds
almost impossible to distinguish between data and separators/qualifiers.
However, it is not impossible because if I open the CSV files directly with
Excel, it correctly spots the difference and shows commas and / or
double-quotes in the data as appropriate.  The same is true if I import the
CSV file into an Access table.  What I am now trying to find out is what
logic is used by Excel / Access to spot the difference so that I can then
use the same logic in my routine!

Regards,

Brian

Quote:
----- Original Message -----


Sent: Saturday, June 09, 2001 9:47 PM
Subject: Re: Reading CSV Files in XL-VBA

> Try changing your Windows Regional Settings to using a semi-colon list
> separator instead of a comma and (if I remember correctly without having
> Excel re-installed on this machine) there's an option of NOT using
> double-quotes for grouping.

> /Lars Hammarberg

>  (If your CSV contains semi-colons within the field data - try another
> separator that's NOT in the text, like or ? or * or whatever)

> ----- Original Message -----

> Newsgroups: microsoft.public.office.developer.vba
> Sent: Saturday, June 09, 2001 21:13
> Subject: Reading CSV Files in XL-VBA

> > Hello,

> > I wonder if anyone could help me?

> > For several days I have been trying to write a routine in VBA (Excel97)
> that
> > will read a CSV file created by another program.  The trouble is, the
CSV
> > file sometimes has double-quotes and / or commas within the field data!

> > I have been going round and round in circles and I would be grateful if
> > anyone could advise me how to solve this problem.

> > Thanks in anticipation,

> > Brian




- Show quoted text -

Quote:
> Hello,

> I wonder if anyone could help me?

> For several days I have been trying to write a routine in VBA (Excel97)
that
> will read a CSV file created by another program.  The trouble is, the CSV
> file sometimes has double-quotes and / or commas within the field data!

> I have been going round and round in circles and I would be grateful if
> anyone could advise me how to solve this problem.

> Thanks in anticipation,

> Brian



Thu, 27 Nov 2003 16:39:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Read XL-sheet with VB4 without XL

2. Read XL-sheet with VB4 without XL

3. Read XL-sheet with VB4 without XL

4. SQL; Select Into Xl-File From XL-File

5. using inputBox to read arrays in VBasic (VBA) over XL

6. XL VBA: Can read ActiveCell

7. using inputBox to read arrays in VBasic (VBA) over XL

8. Save XL file but don't want XL to prompt user

9. Reading a comma separated variable file? (.csv file)

10. VBA - Import Data from CSV File

11. Read CSV files in VB.NET

12. New to VB.net - need to read CSV File into Data Grid

 

 
Powered by phpBB® Forum Software