...

View Full Version : Need help on Parsing CSV file



hanudude
07-19-2011, 02:04 PM
hi,
I am a newbie. Using Java script, I need to open and read CSV file. I need to read the third column values and store in an array.

Please help me regarding this.

Thanks,
Hanumanth.

jmrker
07-19-2011, 03:04 PM
See this thread, among others available with a forum search.
http://www.codingforums.com/showthread.php?t=137102

rnd me
07-19-2011, 06:07 PM
sandbox demo of csv parsing (http://danml.com/sandbox/#var%20rows=IN.value.split%28%22\n%22%29;%0Avar%20colNames=rows[0].split%28%22\t%22%29%0Avar%20data=%20rows.slice%281%29.map%28function%28row,rn%29{%0A%20%20var%20ob= {};%0A%20%20row.split%28%22\t%22%29.map%28function%28cell,cn%29{ob[colNames[cn]]=cell;%20}%29;%0A%20%20return%20ob;%0A}%29;%0A%0A%0Adata)
click the "IN" tab, paste your data into the lower box, click the "OUT" tab, and then click "Run".


hmm, that was tab-delim, my bad.
use this link (http://danml.com/sandbox/#var%20rows=IN.value.split%28%22\n%22%29;%0Avar%20colNames=rows[0].split%28%22,%22%29%0Avar%20data=%20rows.slice%281%29.map%28function%28row,rn%29{%0A%20%20var%20ob={ };%0A%20%20row.split%28%22\t%22%29.map%28function%28cell,cn%29{ob[colNames[cn]]=cell;%20}%29;%0A%20%20return%20ob;%0A}%29;%0A%0A%0Adata) instead.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum