[AccessD] Exporting/Importing CSV files

David Emerson newsgrps at dalyn.co.nz
Thu Oct 9 22:21:39 CDT 2008


Thanks Stuart,

The csv file is actually made up of data from several tables appended 
one after another with dividing records with header info for each section.

Your parsing suggestion seems to be the way to go.

David

At 10/10/2008, you wrote:
>The simplest solution is to export/import as Tab delimited rather 
>than comma delimited
>
>If you can't do that, you will need to read the full line in as a 
>single string and them parse
>it yourself using the quote/comma/quote string as a delimiter.
>
>Input lngFileHandl, strRecord
>'strip beginning and ending quotes'
>strRecord = mid$(strRecord,2,len(strRecord)-2)
>strData() = split(strRecord,"','")
>
>
>On 10 Oct 2008 at 13:10, David Emerson wrote:
>
> > 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
>
>
>--
>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