On Wed, Jan 30, 2013 at 2:23 PM, Dave Angel wrote:
> On 01/30/2013 05:43 AM, inshu chauhan wrote:
>
>> On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber > >wrote:
>>
>> On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
>>> declaimed the following in
>>> gmane.comp.python.general:
>>>
>>> In t
On 01/30/2013 05:43 AM, inshu chauhan wrote:
On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wrote:
On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
declaimed the following in
gmane.comp.python.general:
In the code below I am trying to read 2 files f1 and f2 , extract some
data
from th
On Wed, Jan 30, 2013 at 9:43 PM, inshu chauhan wrote:
> I actually dont want nested loops but cant find another way to achieve what
> I want, But for these files I am sure that they have equal lengths, thats
> why I am taking the risk of using nested loops.. Can you suggest any
> different way to
On Mon, Jan 28, 2013 at 6:05 PM, Dennis Lee Bieber wrote:
> On Mon, 28 Jan 2013 14:31:31 +0100, inshu chauhan
> declaimed the following in
> gmane.comp.python.general:
>
> > In the code below I am trying to read 2 files f1 and f2 , extract some
> data
> > from them and then trying to write them i
On 28-Jan-2013 15:49, Chris Angelico wrote:
On Tue, Jan 29, 2013 at 1:37 AM, Dave Angel wrote:
What you want is the zip() function
for l,s in zip(f1, f2):
#you now have one line from each file,
# which you can then validate and process
Note, this assumes that when a line is "bad"
>>
>>
>>
> That's "zip" not "Zip"
>
> Have you tried looking at the docs? Or even typing help(zip) at the
> python interpreter prompt?
>
> In rough terms, zip takes one element (line) from each of the iterators,
> and creates a new list that holds tuples of those elements. If you use it
> in t
On 01/28/2013 09:47 AM, inshu chauhan wrote:
Your current logic tries to scan through the first file, and for each line
that has 12 elements, scans through the entire second file. It fails to
actually do it, because you never do a seek on the second file.
Now it appears your requirement is en
as an in-memory list. itertools.izip and the built-in python 3 zip
return iterators.
Hope that helps,
Wolfgang
From: inshu chauhan [mailto:insidesh...@gmail.com]
Sent: Monday, January 28, 2013 2:32 PM
To: python-list@python.org
Subject: Reading data from 2 different files and writing to a single
Your current logic tries to scan through the first file, and for each line
that has 12 elements, scans through the entire second file. It fails to
actually do it, because you never do a seek on the second file.
>
> Now it appears your requirement is entirely different. I believe you have
> two t
On Tue, Jan 29, 2013 at 1:37 AM, Dave Angel wrote:
> What you want is the zip() function
>
> for l,s in zip(f1, f2):
> #you now have one line from each file,
> # which you can then validate and process
>
> Note, this assumes that when a line is "bad" from either file, you're going
> to a
On 01/28/2013 09:12 AM, inshu chauhan wrote:
Yes Chris, I understand, My Original code was
for l in f1:
sp = l.split(",")
if len(sp)!= 12:
continue
else:
ix = sp[0].strip()
iy = sp[1].strip()
for s in f2:
st = s.split(",")
if l
On Tue, Jan 29, 2013 at 1:24 AM, inshu chauhan wrote:
>> In that case, Dave's suggestion to read into a list and iterate over
>> the list is to be strongly considered. But I'm not entirely sure what
>> your goal is here. Are you trying to make the Cartesian product of the
>> two files, where you h
> In that case, Dave's suggestion to read into a list and iterate over
> the list is to be strongly considered. But I'm not entirely sure what
> your goal is here. Are you trying to make the Cartesian product of the
> two files, where you have one line in the output for each possible
> pair of matc
On Tue, Jan 29, 2013 at 1:12 AM, inshu chauhan wrote:
> where f1 contains something like :
>
> 297, 404, ,
> 298, 404, , ..
> 299, 404, .
> . ..
> 295, 452,
>
> and f2 contains something like :
>
> 7
> . 2
> 2
> .7
>
> and what I want to be written in th
Yes Chris, I understand, My Original code was
for l in f1:
sp = l.split(",")
if len(sp)!= 12:
continue
else:
ix = sp[0].strip()
iy = sp[1].strip()
for s in f2:
st = s.split(",")
if len(st)!= 11:
continue
else:
On 01/28/2013 08:31 AM, inshu chauhan wrote:
In the code below I am trying to read 2 files f1 and f2 , extract some data
from them and then trying to write them into a single file that is 'nf'.
import cv
f1 = open(r"Z:\modules\Feature_Vectors_300.arff")
f2 = open(r"Z:\modules\Feature_Vectors_300
- Original Message -
>
> - Original Message -
>
> > In the code below I am trying to read 2 files f1 and f2 , extract
> > some data from them and then trying to write them into a single
> > file
> > that is 'nf'.
>
> [snip code]
>
> > I think my code is not so correct , as I am
On Tue, Jan 29, 2013 at 12:31 AM, inshu chauhan wrote:
> I think my code is not so correct , as I am not getting desired results...
Firstly, what results are you getting, and what are you desiring? It
helps to be clear with that.
> import cv
What module is this? Do you need it? Does it affect t
In the code below I am trying to read 2 files f1 and f2 , extract some data
from them and then trying to write them into a single file that is 'nf'.
import cv
f1 = open(r"Z:\modules\Feature_Vectors_300.arff")
f2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")
nf = open(r"Z:\modules\trial.arf
19 matches
Mail list logo