Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: CSV to array

  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question CSV to array

    Hello fellow Javascript users

    I am keen to have a simple script that reads a csv file in the samefolder as my html page and puts it in a javascript array. I succeeded in getting a script to display the casv file as a table on the html page however it would be extremely useful to get the csv data into an array. I have been using jquery but I must be making some major errors.

    Rory Barrett

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,983
    Thanks
    56
    Thanked 557 Times in 554 Posts
    in broad terms, you would make an ajax call, get the content of the csv file, and use the javascript split() method to split that content on the commas, which results in a useable array.

    It's about 99% likely that your existing code only needs a minor tweak to get that happening. In fact, I'm curious as to how you get the CSVs into a table without doing the above or something similar. Can you post your working code?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •