From: Venks Date: 2007-12-07T01:45:20+09:00 Subject: Re: Capturing STDOUT from a system call (POSIX) into an array Thanks. Unfortunately I learned the hard way that if I use back ticks to execute an external command STDERR is not captured. I need to check the status of the command before proceeding. I am looking into "systemu" library as I may need to use threads as part of this development process. On Dec 6, 2007 11:10 AM, Ken Bloom wrote: > On Wed, 05 Dec 2007 19:38:35 -0500, Venks wrote: > > > Thanks for your quick reply. I realize that you don't even need to use > > split. What I am missing is how to create a 2 dimensional array with > > each line contents in an array assuming that they are separated by a > > COMMA. > > > > Let me be more specific. Assume that we have a file under /tmp/test.txt > > with the following contents. > > > > aaa, 10, test1 > > bbb, 20, test2 > > ccc, 30, test3 > > ddd, 40, test4 > > > > I want to create a 2 dimensional array with each line being an array. > > > > lines = `cat /tmp/test.txt` will create a single dimensional array by > > default. > > `cat /tmp/test.txt` will create a single string. > > require 'csv' > nested_arrays=CSV.parse(`cat /tmp/test.txt`) > > > --Ken > > -- > Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. > Department of Computer Science. Illinois Institute of Technology. > http://www.iit.edu/~kbloom1/ > >