replace "|" with " | " (that's space-pipe-space), do your parse, and
then trim everything coming out of it.

cheers,
barneyb

On Tue, Jun 10, 2008 at 3:18 PM, Les Mizzell <[EMAIL PROTECTED]> wrote:
> I've set up a function for a client to import lists of email addresses
> from "|" delimeted files generated from Excel spreadsheets. There's a
> specific format that they always use:
>
> firstname|lastname|emailaddress|other
>
> No problems. The code below works fine:
>
> ----------------------------------------------
>
> <cfloop from="1" to="#ArrayLen(queryFromFile)#" index="i">
>
>   <cfset fromARRAY = #queryFromFile[i]#>
>   <cfset emailLIST = "">
>   <cfset emailLIST = ListAppend(emailLIST,fromARRAY,"|")>
>
> <!--- IF THE ROW DOES NOT HAVE ALL 4 ELEMENTS, SKIP IT --->
> <cfif ListLen(emailLIST,"|") EQ 4>
>  <cfset req.firstname = ListGetAt(emailLIST,1,"|")>
>  <cfset req.lastname = ListGetAt(emailLIST,2,"|")>
>  <cfset req.email = ListGetAt(emailLIST,3,"|")>
>  <cfset req.other = ListGetAt(emailLIST,4,"|")>
> </cfif>
>
> .... then check for valid email address and insert the row
>     into the database...
>
> ----------------------------------------------
>
> But, they need to import a bunch of new list that may *not* have all
> four fields for each row, so I could end up with a list looking like:
>
> firstname|lastname|emailaddress|other
> firstname||emailaddress|other
> |lastname|emailaddress|other
>
> Since the empty fields are ignored, everything gets snockered up into
> the wrong columns.
>
> What's going to be my best way to assign a null or empty value to the
> empty elements so everything ends up in the correct column? Been working
> on this for awhile, but haven't found a great solution yet
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307204
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to