So, would I loop through the array to insert the data into a table?

-----Original Message-----
From: Charlie Griefer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 25, 2005 3:13 PM
To: CF-Talk
Subject: Re: converting text file to data

<cffile action="read" file="c:\inetpub\wwwroot\mytext.txt"
variable="myText">
<!--- insert the proper path above :)  --->

<cfscript>
        myArray = arrayNew(1);
        
        for (i=1; i LTE listLen(myText, chr(13)&chr(10)); i=i+1) {
                myArray[i] = structNew();
                myArray[i].position = i;
                myArray[i].value = listGetAt(myText, i, chr(13)&chr(10));
        }
</cfscript>
<cfdump var="#myArray#">

you don't necessarily need to store the "position" variable, since the
iteration of the loop (and resultant position in the array) will
indicate that.  if there's no other factors that I'm overlooking, you
should be able to just store each element in an array (without the
nested structs).

On 10/25/05, Richard Colman <[EMAIL PROTECTED]> wrote:
> I need to read a file like:
>
>
>
> -1.2
>
> -0.0
>
> -189.7
>
> 0.6
>
> 44.6
>
> -12.3
>
> -1.9
>
> -85.9
>
> 16.3
>
> -197.3
>
> 20.6
>
> -1.6
>
> 0.0
>
> -25.1
>
> -53.7
>
> 17.4
>
>
>
> And insert each value into a data table, like:
>
>
>
> First Record: 1, -1.2
>
> Second Record: 2, -0.0
>
> Third Record: 3, -189.7
>
>
>
> Etc.
>
>
>
> I am not sure how to parse the text file and do the insert. Can anyone
offer
> a suggestion?
>
>
>
> Thank you.
>
>
>
> Rick Colman
>
>
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222250
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

Reply via email to