test
>Hello all!
>This is probably easy stuff for most.
>How do I handle null values in the source csv file when importing into db.
>The following lines of code work only when there is no null value in the
>source file.
>Also how do I handle commas that are in the data itself.
>Is there a custom tag or cf based utility that does all that which I can
>execute from a cf template?
>Codes that work only when the source file has no null fields or commas:
>
><!--- get and read the CSV file --->
><cffile action="read" file="Somefile.csv" variable="csvfile">
>
><!--- loop through the CSV file on line breaks and insert into
>database --->
><cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
> <cfquery name="importcsv" datasource="somedatasource">
> INSERT INTO Table1
>(modelno,details,dealerpartno,rrp,costprice,brand,subcategory)
> VALUES
> ('#listgetAt('#index#',1, ',')#',
> '#listgetAt('#index#',2, ',')#',
> '#listgetAt('#index#',3, ',')#',
> '#listgetAt('#index#',4, ',')#',
> '#listgetAt('#index#',5, ',')#',
> '#listgetAt('#index#',6, ',')#',
>
> '#listgetAt('#index#',7)#'
> )
> </cfquery>
></cfloop>
>Mush appreciate any help.
>Thanks heaps.
>Ben.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236283
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54