Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / August 2006



Tip: Looking for answers? Try searching our database.

Handling empty values in tab delimited file.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lumpia - 29 Aug 2006 21:43 GMT
Developers,

    In regards to the same question asked by rowbeast here:

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21742253.html?qi
d=21742253 ,  the accepted answer states to use the ListFix function from:
http://www.cflib.org/library.cfm?ID=1 .  

     My question is, where do you append this ListFix function within your
code?  I have downloaded the function and am calling it, but do not know how to
insert it on top of a #listgetat# function.  

Here is my code:

<cfinclude template="ListFix.cfm">

<!--- get and read the CSV-TXT file --->
<cffile action="read" file="csvdemo.txt" variable="csvfile">

<!--- loop through the CSV-TXT file on line breaks and insert into database
--->
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
    <cfquery name="importcsv" datasource="#database#" username="#dbid#"
password="#dbpass#">
         INSERT INTO csvdemo
           (COLOR,
           SIZE,
           INSTOCK,
           STYLE)
         VALUES
          ('#listgetAt('#index#',1, chr(9))#',
           '#listgetAt('#index#',2, chr(9))#',
           '#listgetAt('#index#',3, chr(9))#',
           '#listgetAt('#index#',4, chr(9))#'        
           )
   </cfquery>
</cfloop>

<!--- use a simple database query to check the results of the import - dumping
query to screen --->
<cfquery name="rscsvdemo" datasource="#database#" username="#dbid#"
password="#dbpass#">
         SELECT * FROM csvdemo
</cfquery>
<cfdump var="#rscsvdemo#">

I have tried multiple tests such as throwing the #listfix# function in front
of the #listgetat# like this:  

'#listfix(listgetAt('#index#',4, chr(9)))#'

but it doesn't work.  Please advise.  

Also, kinda unrelated to the listfix function, I heard you could use ISNULL
function as seen here:  
http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_20546746.html

but I cannot get it to work either with my code.  I've used it like so:

'ISNULL(#listgetAt('#index#',4, chr(9))#,'')'

Any and all help would be greatly appreciated.
alexfrates - 30 Aug 2006 16:48 GMT
ListFix documentation states that the function defaults to comma separator and
null values. In your case, you are trying to loop over a tab delimited list.
change this line and see if it works:

'#listfix(listgetAt('#index#',4, chr(9)))#'

to

'#listfix(listgetAt('#index#',4, chr(9)), chr(9))#'
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.