ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hello
i have a very tedious task to be automated:
i am running a computational analysis, and i need to edit MANY time the coordinates on a file..
the file is a txt, and the coordinate to be edited are those:
lines before (which i don't need to edit) SDEF pos= x y z blabla blablabla
lines after (which i don't need to edit)
i need to edit them taking from a list of coordinates in another file txt i can provide; and the script should output N new files (where N is the number of coordinates i have to examine) each one with a tag number (example sample1, sample2..)
So in short it should edit a file N times, saving each time it edits with a different name.
please help me i have to edit 3580 times the file, the coordinates needed are just 70 but i've to consider many different cases..
Thanks!!
yes:
the file with the coordinates is a 70 lines simple TXT file made like that:
1 x y z
2 x y z
3 x y z
where the line number should be used in the output file name.
i need only 70 output files because this is the most tedious work:
i am calculating for energy ranges so what i do is basically this, i choose an energy range and write to the file
then i make 70 files for all the coordinates and launch the analysis
once is done i collect the data in a excel sheet and i pass to the next energy by editing the main file
then again i make 70 files out of the template changing only the coordinates.
and so on..
what i need the script for is avoiding the work of editing 70 times the main file, by getting 70 duplicate files where only the coordinate value has been changed..
i need 3580 analisys in total but this i need to do myself, the important is automating the coordinate change or i will get crazy or very likely make an error..
Last edited by assasukasse; 10-25-2006 at 05:55 AM.
c definizione della sorgente
SDEF pos=6.45 0 10.634 axs=0 0 1 par=2 ERG=0.662 CEL=11
RAD=D1 EXT=D2
SI1 0 0.55
SI2 0.5
c fine definizione della sorgente
c mat cards /cut
what i need to edit is the value pos=x y z
the output file should be a copy of the imput file with the coordinate changes according to the coordinate file that should have this form:
1 x y z
2 x y z
3 x y z
...
for example if i have only 3 coordinate files i should get 4 files:
one is the original, and 3 are the modified coordinate ones
so if original is sample
i will have the following 4 files: sample, sample1 (which has been modified to have pos=x y z as in line 1 of coordinate file), sample2, sample3
i found a small problem with the script:
if i choose a clearly wrong file as a template for the coordinates
it tells me that maybe i am wrong since there are letters too
but proceed anyway making a bunch of wrong files...
is there any way to stop the generation of files in case a letter is encountered?
thanks
hi bigersbilli i incurred in a small problem
i have the need to process files that have tabs instead of spaces between the coordinates.
or even better, to ignore if there is 1-4-5-6 or whatever spaces in between the numbers, or even tabs..
do i need to change anything?
Thanks
Last edited by assasukasse; 01-04-2007 at 04:36 PM.
Thanks muha
i need more time to study sed, i made some tests but i didn't go much farther..
however, i was thinking i missed something when in the file bigearsbilly gave me:
there is another line that needs to be edited
the line is BEFORE the SDEF line
and starts with 14 RCC then 5 spaces, then the same coordinates of SDEF then other numbers..
now i added the following line to the pl file:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.