You can pass the read data directly to R.  Probably the best way to  
do this is to construct a python list containing one vector per  
column.  Call as.data.frame() on the list, and then proceed.

For example:


        from rpy import *
        set_default_mode(NO_CONVERSION)
        data = [ [ 1, 2, 3], ["A","B","C"], [1.08, 1.334, 3.12] ]
        df = r.as_data_frame(data)
        r.print_(df)


-Greg   




On Apr 1, 2008, at 5:40AM , Peter wrote:
> Hi Lukasz,
>
> If your data has all the elements of the same type, then you could try
> loading it into a NumPy matrix or array, and passing that to R.
>
> I personally would pass the filename to R, and use R's read.table()
> command to load it in R.  You can work out the exact options you need
> for read.table() by experimenting in an R session, and then try the
> same from rpy.  This assumes you do not need the actual data in python
> too.
>
> I don't know if you can pass the file pointer (handle) from python to
> R.  I would be interested to know if this is possible.
>
> Peter
>
> On Tue, Apr 1, 2008 at 2:51 AM, Lukasz Szybalski  
> <[EMAIL PROTECTED]> wrote:
>> Hello,
>>  I am trying to read a 100mb+ csv file in python.
>>  f=csv.DictReader(open(filename))
>>  or
>>  f=csv.Reader(open(filename))
>>
>>  When I read it in I would like to pass it to R to do some work on  
>> it.
>>  How would I do that?
>>
>>  Do I pass the file pointer or read file?
>>  I think for speed purposes I would prefer passing read file.
>>
>>  Lucas
>
> ---------------------------------------------------------------------- 
> ---
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
> marketplace
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to