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
https://forums.phpfreaks.com/topic/275202-csv-to-array/
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
https://forums.phpfreaks.com/topic/275202-csv-to-array/#findComment-1416500
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.