different
Something like:
<cfoutput>
<cfloop index="i" from="2" to="#ArrayLen(file_array)#"> x being value of my
first loop (to
count records)
<cfloop index="j" from="1" to="#ArrayLen(file_array[i].Personnel)#"> y
being value of my second loop (to
count person on each row)
#file_array[i].Personnel[j]#<br>
</cfloop>
</cfloop>
</cfoutput>
To see what the array looks like do a <CFDUMP var="#file_array#"> give you a
better idea of what your working with.
-----Original Message-----
From: CHALLEL Nicolas PREF54
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 21, 2004 10:15 AM
To: CF-Talk
Subject: RE: txt file which lines don't have the same length
Thanks for your precious help.
I just don't really know how to display my datas...
I tried something like that
<cfoutput>
<cfloop index="i" from="2" to="#x#"> x being value of my first loop (to
count records)
<cfloop index="j" from="1" to="#y#"> y being value of my second loop (to
count person on each row)
#file_array[i].Personnel[j]#<br>
</cfloop>
</cfloop>
</cfoutput>
but the 4th line <!---#file_array[i].Personnel[j]#---> returns an error
message to me :
"that the element at position 1 in dimension 1 of object "PERSONNEL" cannot
be found. That dimension of the object is empty. Please, modify the index
_expression_"
Should I use Struct functions to display ?
-----Message d'origine-----
De : Bruce, Rodney S HQISEC/Veridian IT Services
[mailto:[EMAIL PROTECTED]
Envoyé : mercredi 21 janvier 2004 17:15
À : CF-Talk
Objet : RE: txt file which lines don't have the same length
This is only one way of doing it, may not be the most efficient, but should
work,
<!----------------------------------------------------pseudo
code------------------------------------------>
<cffile action="" file="#expandPath('.')#\T128.TXT" variable="message">
<!---- I would use an array of structures-------->
<!-----
File_Array= ArrayNew(1) -----Main Array to hold all structues---
File_Array[x]= StructNew ------Holds Location information----
File_Array[x].Personnel = ArrayNew(1) ----Array to hold personnel
information for each location---
File_Array[x].Personnel[x] = StructNew -----Struct to hold each
persons information------------------
------------------>
<cfset file_array = ArrayNew(1)>
<cfset x = 1>
<cfloop index="rc" list="#message#" delimiters=",#chr(10)#">
<!-------Grab each row one at a time---------------------->
<cfset TempRecord = rc>
<cfset file_array[x] = Structnew()>
<cfset file_array[x].RecordNo = x> ---Assumes that record number
is with location not person---
<cfset file_array[x].date = ListGetAt(TempRecord, 1, ";" )>
<cfset file_array[x].code = ListGetAt(TempRecord, 2, ";" )>
----do same for next 4 elements------
<cfset file_array[x].Personnel = ArrayNew(1)> ---sets array to hold
structure for persons--
<cfset y=1>
<cfloop index="z" from="7" to="#ListLen(TempRecord)#" Step="3">
<cfset file_array[x].Personnel[y]=StructNew()>
<cfset file_array[x].Personnel[y].LastName =
ListGetAt(TempRecord, z, ";")>
<cfset file_array[x].Personnel[y].FirstName =
ListGetAt(TempRecord, z+1, ";")>
<cfset file_array[x].Personnel[y].PValue=
ListGetAt(TempRecord, z+2, ";")>
<cfset y = y+1>
</cfloop>
<cfset x = x+1>
</cfloop>
Then you can display by looping thru the array
This is really quick and off the top of my head, you may need to work with
it some to get it just right for yourself.
others can probley tune it up.
but hope it helps point you in right direction.
-----Original Message-----
From: Nicolas CHALLEL
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 21, 2004 1:48 AM
To: CF-Talk
Subject: Re:txt file which lines don't have the same length
Hello and thanks for your help.
I manage to proceed with a file counting 6 fix entries for each row,
separated by comma (;).
But I can't proceed with variable entries...
<!--- I use <cffile> tag to read my txt file and declare an array to put
each entry --->
<cffile action=""
file="#expandPath('.')#\T128.TXT" variable="message">
<cfset file_array = ArrayNew(1)>
<cfloop index="rc" list="#message#" delimiters=",#chr(10)#">
<cfset rc = ArrayAppend(file_array, rc)>
</cfloop>
<!---I set the starting record, skipping the first 6 that are 'fixed'--->
<cfset a = 7>
<cfset b = 8>
<cfset c = 9>
<cfset d = 10>
<cfset e = 11>
<cfset f = 12>
<cfset g = 13>
<cfset h = 14>
<cfset i = 15>
<!---Get the record count and subtract 1 to skip the first row--->
<cfset loop_end = (#arrayLen(file_array)#/6)-1>
<!---Then I loop through the records displaying 6 at a time which makes up
one row of data but I don't treat variables entries--->
<cfloop index="i" from="1" to="#loop_end#">
<cfoutput>
<hr width="200" align="left">
Record Number: #i<br>
Date: #file_array[a]#<br>
Code: #file_array[b]#<br>
Lib: #file_array[c]#<br>
Value1: #file_array[d]#<br>
Value2: #file_array[e]#<br>
Value3: #file_array[f]#<br>
Name: #file_array[g]#<br>
First Name: #file_array[h]#<br>
Value: #file_array[i]#<br>
</cfoutput>
<cfset a = a + 6>
<cfset b = b + 6>
<cfset c = c + 6>
<cfset d = d + 6>
<cfset e = e + 6>
<cfset f = f + 6>
<cfset g = g + 6>
<cfset h = h + 6>
<cfset i = i + 6>
</cfloop>
Instead of getting
_______________
Record Number 1
13/01/2004 11:36
345
London
00000025
00000415
00000012
SMITH
Deborah
00000085
_______________
Record Number 2
13/01/2004 11:36
202
Paris
00000144
00000002
00000711
CLIFTON
Jack
00000055
COLLINS
Jenifer
00000033
_______________
Record Number 3
13/01/2004 11:36
711
TOKYO
00000125
00000075
00000102
PAUL
Sean
00000077
BOSTON
Mickael
00000114
CHRIS
Helen
00000072
I get
_______________
Record Number 1
13/01/2004 11:36
345
London
00000025
00000415
00000012
SMITH
Deborah
00000085
_______________
Record Number 2
13/01/2004 11:36
202
Paris
00000144
00000002
00000711
CLIFTON
Jack
00000055
_______________
Record Number 3
COLLINS
Jenifer
00000033
13/01/2004 11:36
711
TOKYO
00000125
00000075
00000102
So it's impossible for me after that to request and try to calculate for
instance the sum of value1+value2+value3
and other stuff like that...
What would you suggest me to do ?
May be counting the number of entries for the longer row and write blank
records in shorter rows before proceeding the file ?
I don't really know what to do.
It would be nice if you have ideas to improve my script.
Thanks a lot.
_____
_____
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

