[AccessD] Exporting/Importing CSV files

Steve Goodhall steve at goodhall.info
Fri Oct 10 08:50:28 CDT 2008


I checked this by exporting and importing a file using Menu, File, Export
and Menu, File, Get External Data.  I start with a table that looks like
this:
Table1
ID	T1	T2
1	T11	T21
2	T2,2	T22
3	T32	T3,2
4	T4,1	T4,2
5	T4"1	T5'2
 
I export it to a CSV format which looks like this:
"ID","T1","T2"
1,"T11","T21"
2,"T2,2","T22"
3,"T32","T3,2"
4,"T4,1","T4,2"
5,"T4""1","T5'2"
I import it and I get:
Table1A
ID	T1	T2
1	T11	T21
2	T2,2	T22
3	T32	T3,2
4	T4,1	T4,2
5	T4"1	T5'2
 
As you see, commas inside double quotes are not a problem.  
I also tried double quotes and single quotes.  Double quotes within the
field need to be changed to 2 double quotes when writing the CSV file.
Regards,
Steve Goodhall, PMP
248-505-5204 mobile

Steve Goodhall, PMP
248-505-5204 mobile


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Friday, October 10, 2008 1:19 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Exporting/Importing CSV files

Is that why they are called CSV files? - <smile>

CSV=Comma Separated Values.  Not only are the "notorious" but "essential"

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Elizabeth.J.Doering at wellsfargo.com
Sent: 10 October 2008 03:16
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Exporting/Importing CSV files

 
David, 

You may have better success removing commas from all fields, all the
time.  CSVs are notorious for being comma separated!  

Either enforce farther back that commas can't be entered in the fields,
or use Replace to get rid of them as you are exporting.

HTH,


Liz   


 
 




-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David Emerson
Sent: Thursday, October 09, 2008 7:11 PM
To: accessd at databaseadvisors.com
Subject: [AccessD] Exporting/Importing CSV files

Team,

I am wanting to export fields into a CSV file.  This I can do using
Print #.  I am also enclosing each field in single quotes thus:

Print #lngFileHandle, "'DET','" & rst!Field1 & "','" & rst!Field2 &
"','" & rst!Field3 & "'"

Result:
'DET','1','Joe','Bloggs','10 Kingston Lane'

I can also read the files back into an arrany using Input #:

Input #lngFileHandle, strData(0), strData(2), strData(3), strData(4)

This works fine unless one of the output fields includes a comma. Eg
'DET','1','Joe','Bloggs','10 Kingston Lane, Jamaca'

In this case the Input# only gets "'10 Kingston Lane" and assumes that "
Jamaca'" is for the next field.

How do I allow for comma's to be included in fields?


Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

This message may contain confidential and/or privileged information. If
you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based on
this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation.


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list