Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4059112
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:09:57+00:00 2026-05-20T15:09:57+00:00

I am trying to load a CSV file into an array using ColdFusion (version

  • 0

I am trying to load a CSV file into an array using ColdFusion (version 7.0.2.142559). Right now I am getting the following error:

A scalar value of type coldfusion.runtime.Struct cannot be assigned to a 2-dimensional ColdFusion array.
A ColdFusion 2-dimensional array can only hold 1-dimensional ColdFusion arrays and Java List objects.

My CSV file is setup in this format:

a,b
c,d
e,f

This is my first go with ColdFusion so I probably have some simple syntax error that I just cannot see. Code is below.

<!--- get the current full path of the current --->
<cfset currentPath = getCurrentTemplatePath()>
<cfset currentDirectory = getDirectoryFromPath(currentPath)>
<!--- get and read the CSV-TXT file --->
<cffile action="read" file="#currentDirectory#/smalltest.csv" variable="csvfile">
<!--- create a new array --->
<cfset array=ArrayNew(2)>
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">

    <cfset array[#index#][1]=#listgetAt('#index#',1, ',')#>
    <cfset array[#index#][2]=#listgetAt('#index#',2, ',')#>

</cfloop>

<cfdump var=#array#>

Bonus:

On a side note it would save me a lot of time if there were some way to call upon a PHP file from within ColdFusion since I already have this entire script completed (this is just a small portion) in PHP. I read about ColdFusion custom tags (the tag <cf_php> would work perfect for me) but admin says no, thus I must work with ColdFusion or find some way to render PHP through ColdFusion. Frames, JavaScript, or the <cfhttp> tag are all things I think might work… if you have an idea let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:09:58+00:00Added an answer on May 20, 2026 at 3:09 pm

    Actually I think you could simplify Henry’s example even further using a one dimensional array and arrayAppend.

    <cfset array=ArrayNew(1)>
    <cfloop index="line" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
        <cfset arrayAppend(array, listToArray(line))>
    </cfloop>
    

    A scalar value of type
    coldfusion.runtime.Struct cannot be
    assigned to a 2-dimensional ColdFusion
    array.

    FYI: The original code is mixing loop types. With <cfloop list=".."> the index value is an element of the list like “a,b” (not a line number). Obviously “a,b” is not the expected numeric index, hence the error.

    <!--- what the code is actually doing --->
    <cfset array['a,b'][1]=#listgetAt('#index#',1, ',')#>
    <cfset array['a,b'][2]=#listgetAt('#index#',2, ',')#>
    <cfset array['c,d'][1]=#listgetAt('#index#',1, ',')#>
    ....
    

    Having nothing to do with your error, none of those # signs are necessary. The code will work either way, but it is cleaner to write:

    <cfset array[lineNum][1]= listgetAt( index, 1, ',')>
    

    instead of

    <cfset array['#lineNum#'][1]=#listgetAt('#index#',1, ',')#>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load a CSV file into a single dimentional array. I can
Im trying to load a csv file into a datatable using oledb. This is
I'm trying to load a CSV file into MySQL, and I keep getting syntax
I am trying to figure out an eazy way to load CSV file into
I'm trying to import a CSV files into my MySQL table using the following
I am trying to load csv file using SQLXMLBULKLOADLib which first converts csv to
I'm trying to Load a CSV file into my MySQL database, But I would
I'm trying to load a .csv file with baseball schedules into a table of
I'm trying to load data from a CSV file into a MySQL database, and
I'm trying to load a CSV into a DataTable using this: class CSVReader {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.