[AccessD] Exporting/Importing CSV files

Drew Wutka DWUTKA at Marlow.com
Fri Oct 10 16:22:28 CDT 2008


Pretty simple to solve.  Every unit except the first and last are
actually split with ',', so read the file in like this:

Dim f as long
Dim strTemp as string
Dim strArray() as string
F=freefile
Open "C:\Folder\File.csv" for binary access read as f
Strtemp=space(lof(f))
Get f,,strtemp
Strarray=split(strtemp,"','")
Close f

Now strArray should contain each field....

Drew

-----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
The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list