Complicated string substitution

2008-02-13 Thread Horacius ReX
Hi, I have a file with a lot of the following ocurrences: denmark.handa.1-10 denmark.handa.1-12344 denmark.handa.1-4 denmark.handa.1-56 ... distributed randomly in a file. I need to convert each of this ocurrences to: denmark.handa.1-10_1 denmark.handa.1-12344_1 denmark.handa.1-4_1

non-uniform string substituion

2008-02-13 Thread Horacius ReX
Hi, I have a file with a lot of the following ocurrences: denmark.handa.1-10 denmark.handa.1-12344 denmark.handa.1-4 denmark.handa.1-56 ... distributed randomly in a file. I need to convert each of this ocurrences to: denmark.handa.1-10_1 denmark.handa.1-12344_1 denmark.handa.1-4_1

Look for a string on a file and get its line number

2008-01-08 Thread Horacius ReX
Hi, I have to search for a string on a big file. Once this string is found, I would need to get the number of the line in which the string is located on the file. Do you know how if this is possible to do in python ? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Look for a string on a file and get its line number

2008-01-08 Thread Horacius ReX
Hi, thanks for the help. Then I got running the following code; #!/usr/bin/env python import os, sys, re, string, array, linecache, math nlach = 12532 lach_list = sys.argv[1] lach_list_file = open(lach_list,r) lach_mol2 = sys.argv[2] # name of the lachand mol2 file lach_mol2_file =

Mix different C source files into a single one

2007-12-29 Thread Horacius ReX
Hi, I have a C program split into different source files. I am trying a new compiler and for some reason it only accepts a single source file. So I need to mix all my different C source files into a single one. Do you know about some type of python script able to do this kind of task ? Thanks

Extract a number from a complicated string

2007-12-21 Thread Horacius ReX
Hi, I have to read some data from a file, and on each block it always appears the followng string; xyz.vs.1-81_1 . It appears a lot of time with different numbers like; xyz.vs.1-81_1 xyz.vs.1-1234_1 xyz.vs.1-56431_1 and so on My problem is that I need to extract from this string the number.

Python; jump to a concrete line

2007-12-20 Thread Horacius ReX
Hi, sorry but after looking for information, I still did not get how, when reading a text file in python, can one jump to a concrete line and then read the different data (separated by spaces). In each line there is different number of columns so sometimes i get kind of index out error. Is there a

Deleting lines from a file

2007-12-17 Thread Horacius ReX
Hi, I need to write a program which reads an external text file. Each time it reads, then it needs to delete some lines, for instance from second line to 55th line. The file is really big, so what do you think is the fastest method to delete specific lines in a text file ? Thanks --

Re: Deleting lines from a file

2007-12-17 Thread Horacius ReX
and regardless of the speed, what do you think would be the best method to do this ? Michael Bentley wrote: On Dec 17, 2007, at 5:34 AM, Horacius ReX wrote: I need to write a program which reads an external text file. Each time it reads, then it needs to delete some lines, for instance

multidimensional arrays

2007-12-06 Thread Horacius ReX
in python, when I want to use arrays, I follow this way; DATA = [0] * nint and when I want to use I do; DATA[i] = do you know how to do similar but in two dimensions ? thanks -- http://mail.python.org/mailman/listinfo/python-list

read lines

2007-12-04 Thread Horacius ReX
Hi, I have a text file like this; 1 -33.453579 2 -148.487125 3 -195.067172 4 -115.958374 5 -100.597841 6 -121.566441 7 -121.025381 8 -132.103507 9 -108.939327 10 -97.046703 11 -52.866534 12 -48.432623 13 -112.790419 14 -98.516975 15 -98.724436 So I want to write a program in python that reads