when using the new CSVWrite function, and arrayOf ...
# adobe
r
when using the new CSVWrite function, and arrayOf Structs, there appears to be no way to associate a struct key with a header. So for example, if my headers are ["Name","Age"] and i have an array of structs that have a Name and Age value, CF doesn't properly put the right data under the right header
an ordered struct seems to help
except - crap - it doesnt 😕
so here's the issue from what i can tell. when i read in a csv file as an array of structs, append a new ordered array, and save - the NEW record works perfectly but the old records are randomly placed 😕
yeah, i can reproduce this
maybe 😉 need to eat and reconsider
n
can you provide a test case and sample output for this?
âž• 1
b
Here is a test case:
<!---  ******* Beginning of code  ******* --->
<cfset data=[{header1:"Position", header2:"Team Name",  header3:"League Points"}, {data1:"1st", data2:"Sporting Club",  data3:"97"}, {data1:"2nd", data2:"The Lions",  data3:"86"}]>
<cfset csvWrite(data,"arrayofstruct",expandpath("testcsvWrite.csv"))>
Done: CSV file written to current directory.
<!---  ******* End of code  ******* --->
Result: League Points,Position,Team Name 97,Sporting Club,1st 86,The Lions,2nd Bug report: https://tracker.adobe.com/#/view/CF-4226587