On Fri, Dec 23, 2011 at 8:19 PM, Andreas Perstinger
wrote:
> On 2011-12-23 12:02, lina wrote:
>>
>> for i in range(len(result)):
>> for j in range(len(result[i])):
>> print(result[i][j])
>>
>> still have a little problem about print out,
>>
>> I wish to get like
>> a a
>> b
On 2011-12-23 12:02, lina wrote:
for i in range(len(result)):
for j in range(len(result[i])):
print(result[i][j])
still have a little problem about print out,
I wish to get like
a a
b b
c c
which will show in the same line,
not as
a
b
c
a
b
c
So you wish to print a
On Fri, Dec 23, 2011 at 3:31 PM, lina wrote:
>
> Hi,
>
[SNIPPED]
> 2] I want to combine a series of files like
>
> a.txt
>
> 1 a
> 2 a
> 3 a
>
> b.txt
>
> 1 b
> 2 b
> 3 b
>
> into one as:
> a b
> a b
> a b
>
Is this ok?
---
On 23/12/11 11:02, lina wrote:
for i in range(len(result)):
for j in range(len(result[i])):
print(result[i][j])
You don't need all the indexing.
Use Pythons for loop to get the items:
for group in result:
for item in group:
print item, # comma prevents
#!/usr/bin/python3
import os
INFILEEXT = ".xvg"
NUM_OF_FILES = 2
if __name__=="__main__":
result = [ [] for i in range(NUM_OF_FILES)]
for i in range(NUM_OF_FILES):
filename = "A_mindist_" + str(i+1) + INFILEEXT
#text = open(filename,"r").readlines()
with open(fi
On Fri, Dec 23, 2011 at 6:42 PM, Alan Gauld wrote:
> On 23/12/11 10:01, lina wrote:
>
>> with open(filename,"r") as f:
>> for line in f:
>> parts = f.readline().strip()
>
>
> Are you sure you want to do this?
> You are already reading a line from the file in the
On 23/12/11 10:01, lina wrote:
with open(filename,"r") as f:
for line in f:
parts = f.readline().strip()
Are you sure you want to do this?
You are already reading a line from the file in the for loop.
This will read the next line. So parts will comprise e
On 23 December 2011 10:01, lina wrote:
> Hi,
>
> 1] How to input some column in idle
>
> like:
>
> a
> a
> a
>
> 2] I want to combine a series of files like
>
> a.txt
>
> 1 a
> 2 a
> 3 a
>
> b.txt
>
> 1 b
> 2 b
> 3 b
>
> into one as:
> a b
> a b
> a b
>
> The work-in-progress code as following,
>
Hi,
1] How to input some column in idle
like:
a
a
a
2] I want to combine a series of files like
a.txt
1 a
2 a
3 a
b.txt
1 b
2 b
3 b
into one as:
a b
a b
a b
The work-in-progress code as following,
#!/usr/bin/python3
import os
INFILEEXT = ".xvg"
NUM_OF_FILE = 10
if __name__=="__main_