![]() |
![]() |
#1 |
Oct 2006
103 Posts |
![]()
Hi,
is there a way to convert the output from srsieve/srfile (.abcd .prp .pfgw) automaticaly into a worktodo.txt for mprime/prime95? |
![]() |
![]() |
![]() |
#2 |
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17×251 Posts |
![]()
If doing a little bit of manual work, you can use a text editor: In any decent text editor (e.g. Notepad++), use regex to find/replace, e.g.
Code:
^(\d+) (\d+)$ Code:
PRP=\1,2,\2,-1 Code:
some header line 456 789456 789 456987 Code:
some header line PRP=456,2,789456,-1 PRP=789,2,456987,-1 Code:
for line in read(input_file): # if it's an actual line and not a header k, n = split(line) print('PRP={},2,{},-1', k, n) |
![]() |
![]() |
![]() |
#3 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
![]() Code:
import re in_file = 'blah.abcd' out = [] with open(in_file) as f: for line in f.readlines(): if re.match(r'^(\d+) (\d+)$', line): k, n = line.split() out.append('PRP={},2,{},-1'.format(k, n)) out_file = 'worktodo.txt' with open(out_file, 'w') as f: f.write('\n'.join(out) + '\n') Code:
out = ['PRP={},2,{},-1'.format(*line.split()) for line in f.readlines() if re.match(r'^(\d+) (\d+)$', line)] Last fiddled with by Dubslow on 2014-10-31 at 15:15 |
![]() |
![]() |
![]() |
#4 |
Oct 2006
103 Posts |
![]()
That's great!
I thought about using 'sed' but regex and I are not the best friends ; ) Thank you both! |
![]() |
![]() |
![]() |
#5 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
24·11·53 Posts |
![]()
awk
For example awk '{print "PRP="$1",2,"$2",-1"}' infile > outfile and then take care of the 1st line (the header) in an editor |
![]() |
![]() |
![]() |
#6 |
"/X\(‘-‘)/X\"
Jan 2013
29·101 Posts |
![]() |
![]() |
![]() |
![]() |
#7 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
221608 Posts |
![]()
Perfectionism notwithstanding, there's no limit what can be further beautified :)
If you have 400 lines in input and 8 cores for Prime95 to follow, awk '{if(NR%50==1){print "[Worker #"int(NR/50)+1"]"} if(NR>1){print "PRP="$1",2,"$2",-1"}}' infile >outfile |
![]() |
![]() |
![]() |
#8 |
Oct 2006
103 Posts |
![]()
This is very helpful!
Is there a way to use sed or awk to create a file for n-cores where every nth-candidate is moved to a certain worker: for example 4 cores: Code:
candidate - > assigned worker 1 1 2 2 3 3 4 4 5 1 6 2 7 3 8 4 ... |
![]() |
![]() |
![]() |
#9 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
24·11·53 Posts |
![]()
Here you will need a bit of perl (probably can be done in awk, but when you get out of one-line volume of code in awk you want to switch to perl). This takes one parameter (or 4 by default) and text on stdin, like this: ./split.pl 6 < aa.npg > worktodo.txt
Code:
#!/usr/bin/perl -w $N = (shift || 4); @A = <>; for($i=1;$i<=$N;$i++) { print "[Worker #", $i, "]\n"; for($k=$i;$k<@A;$k+=$N) { $A[$k] =~ /(\d+) (\d+)/; print "PRP=$1,2,$2,-1\n"; } } Last fiddled with by Batalov on 2014-10-31 at 23:08 Reason: (P.S.) |
![]() |
![]() |
![]() |
#10 |
Oct 2006
11001112 Posts |
![]()
Again: Thank you!
This will do it for me. |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bug in srfile 1.0.6 | pepi37 | Software | 6 | 2017-05-25 17:51 |
where is prime95 keeping my prime, local, worktodo files? | almostfrugal | Information & Answers | 4 | 2012-09-19 03:51 |
Regenerating the worktodo files from PrimeNet? | LaurV | PrimeNet | 3 | 2012-03-28 17:40 |
srfile | justinsane | Software | 2 | 2009-07-20 16:27 |
P-1 and srfile | henryzz | Factoring | 7 | 2008-11-04 17:01 |