On 12/18/11 12:33, traveller3141 wrote:
To test this, I made a small sample file (sillyNums.txt) as follows;
109
345
2
1234556
f=open("sillyNums.txt","r")
data = array.array('i')
data.fromstring(f.read(data.itemsize* bufferSize))
print data
The output was nonsense:
array('i', [171520049, 171258
traveller3141 wrote:
> I've been trying to use the Array class to read 32-bit integers from a
> file. There is one integer per line and the integers are stored as text.
> For problem specific reasons, I only am allowed to read 2 lines (2 32-bit
> integers) at a time.
>
> To test this, I made a sm
I've been trying to use the Array class to read 32-bit integers from a
file. There is one integer per line and the integers are stored as text.
For problem specific reasons, I only am allowed to read 2 lines (2 32-bit
integers) at a time.
To test this, I made a small sample file (sillyNums.txt) as
Aahz wrote:
> In article ,
> Tim Chase wrote:
>>> Assuming this is a real task and not a homework problem, then
>>> I'd do it this way:
>>>
>>> $ cd [directory containing 50 test files]
>>> $ (for file in *; do head -n11 $file | tail -n5; done)
>>> >/path/to/results-file.txt
>> I'd use sed:
On Feb 17, 11:03 am, oamram wrote:
> Hi All,
> new to python. i have a directory with about 50 text file and i need to
> iterate through them and get
> line 7 to 11 from each file and write those lines into another file(one file
> that will contain all lines).
>
import glob
file("output.txt","w")
In article ,
Tim Chase wrote:
>> Assuming this is a real task and not a homework problem, then
>> I'd do it this way:
>>
>> $ cd [directory containing 50 test files]
>> $ (for file in *; do head -n11 $file | tail -n5; done)
>> >/path/to/results-file.txt
>
>I'd use sed:
>
> sed -ns 7,11p /
On 2009-02-17, Tim Chase wrote:
>> Assuming this is a real task and not a homework problem, then
>> I'd do it this way:
>>
>> $ cd [directory containing 50 test files]
>> $ (for file in *; do head -n11 $file | tail -n5; done)
>> >/path/to/results-file.txt
>
> I'd use sed:
>
>sed -ns 7,11
Assuming this is a real task and not a homework problem, then
I'd do it this way:
$ cd [directory containing 50 test files]
$ (for file in *; do head -n11 $file | tail -n5; done)
>/path/to/results-file.txt
I'd use sed:
sed -ns 7,11p /source/path/*.txt >/path/to/results.txt
hard to get
On 2009-02-17, oamram wrote:
> i have a directory with about 50 text file and i need to
> iterate through them and get line 7 to 11 from each file and
> write those lines into another file(one file that will contain
> all lines).
Assuming this is a real task and not a homework problem, then
I'd
bearophileh...@lycos.com wrote:
oamram:
i have a directory with about 50 text file and i need to
iterate through them and get
line 7 to 11 from each file and write those lines into another
file(one file that will contain all lines).
Files can be iterated line-by-line, so this idiom:
for line
oamram:
> i have a directory with about 50 text file and i need to
> iterate through them and get
> line 7 to 11 from each file and write those lines into another
> file(one file that will contain all lines).
Files can be iterated line-by-line, so this idiom:
for line in file: ...
will give you
oamram a écrit :
Hi All,
new to python. i have a directory with about 50 text file and i need to
iterate through them and get
line 7 to 11 from each file and write those lines into another file(one file
that will contain all lines).
First create a function that read and parse one file
Then cre
-from-text-tp22061427p22061427.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
A. Joseph wrote:
I want to read from text file, 25 lines each time i press enter key,
just like the python documentation.
you can use pydoc's pager from your program:
import pydoc
text = open(filename).read()
pydoc.pager(text)
--
http://mail.python.org/mailman/listinfo/python-
I want to read from text file, 25 lines each time i press enter key,
just like the python documentation.
i`m using Python 2.5, Windows XP
Thank you
--
http://mail.python.org/mailman/listinfo/python-list
15 matches
Mail list logo