Jump to content

CSV To Array


doublet216

Recommended Posts

I am stuck getting a CSV file that I upload into an array in javascript.   So far my file upload gives me.

 

param_name,param_val "name2","value2" "name","value" "name1","value1"

 

I need to just grab the values inside the " ".  So I would need an array to go like

 

array(

[0] name2 => value 2

[1] name => value

[2] name1 => value 1

)

 

I am stuck and can't seem to get it how I need it.   Can anyone help? I have tried replacing and splitting but with no such luck.  Any push in the right direction is appreciated. 

 

 

 

My Excel CSV looks like this

 

param_name | param_val

name 2          | value2

name             | value

name1           | value1

Link to comment
Share on other sites

If you save as .csv then each row should look like

 

 

value1,value2

 

or 

 

"value1","value2"

 

 

..but you are showing pipes...are you just using pipes in your post or is that what you really have in your file? 

 

in any case...are you sure this is javascript you are talking about?  javascript cannot read files...well, I guess if you have an ActiveX object...is that what you have?  Or are you uploading the file and then using php or some other server-side language to respond w/ the contents (i.e. ajax)?  IOW, how are you opening the file and getting the data to javascript? 

Link to comment
Share on other sites

If you save it as a .csv file, it's not an excel file anymore, and we are back to my original question of what the actual text looks like. But that all said, all the questions raised in the last post are relevant.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.