Currently there may be errors shown on top of a page, because of a missing Wiki update (PHP version and extension DPL3).
Navigation
Topics Help • Register • News • History • How to • Sequences statistics • Template prototypes

Difference between revisions of "Splitting a sieve file"

From Prime-Wiki
Jump to: navigation, search
m
(Extension was changed in last edit; adding Linux instructions)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Description==
 
==Description==
Splitting a sieve file in [[PRP-LLR format]] into a number of seperate files using [[awk]].
+
Splitting a sieve file in [[PRP-LLR format]] into a number of separate files using <code>[[wikipedia:AWK|awk]]</code>.
  
 
==Needed software==
 
==Needed software==
 
*ASCII editor
 
*ASCII editor
*awk.exe
+
*<code>awk.exe</code> (included by default on Linux)
  
 
==Example==
 
==Example==
 
Split the sieve file <code>t16_b999.prp</code> into 4 separate files.
 
Split the sieve file <code>t16_b999.prp</code> into 4 separate files.
  
==Preparation WIN==
+
===Preparation WIN===
*copy <code>gawk.exe</code> in a folder
+
*Copy <code>gawk.exe</code> in a folder
*create a file named <code>split.awk</code> with this code:
+
*Create a file named <code>split.awk</code> with this code:
 
<pre>
 
<pre>
BEGIN{getline line; i=1}
+
BEGIN {getline line; i=1}
{if (head[i] == 0)
+
{
   {print line >>i".pfgw"
+
  if (head[i] == 0)
 +
   {
 +
    print line >>i".txt"
 
     head[i]=1
 
     head[i]=1
 
   }
 
   }
   print $0 >>i".pfgw"
+
   print $0 >>i".txt"
 
   i++
 
   i++
   if (i==5) i=1
+
   if (i==files+1) i=1
}
+
}
 
</pre>
 
</pre>
*copy the sieve file in this folder (for example <code>t16_b999.prp</code>
+
*Copy the sieve file in this folder (for example <code>t16_b999.prp</code>).
*calling <code>gawk -f split.awk t16_b999.prp</code>
+
*Call <code>gawk -f split.awk files=4 t16_b999.prp</code>.
  
 
Results:
 
Results:
*creates 4 files <code>1.pfgw</code> to <code>4.pfgw</code> with equally splitted candidates sorted by n
+
*Creates 4 files <code>1.txt</code> to <code>4.txt</code> with equally split candidates sorted by {{Vn}}.
  
 +
===Preparation LINUX===
 +
*<code>awk</code> is probably already present on your computer.
 +
*Create a file named <code>split.awk</code> with the same code as above.
 +
*Copy the sieve file in this folder (for example <code>t16_b999.prp</code>).
 +
*Call <code>awk -f split.awk files=4 t16_b999.prp</code>.
 +
 +
Results:
 +
*Creates 4 files <code>1.txt</code> to <code>4.txt</code> with equally split candidates sorted by {{Vn}}.
  
 
[[Category:Code snippets]]
 
[[Category:Code snippets]]

Latest revision as of 18:52, 2 October 2022

Description

Splitting a sieve file in PRP-LLR format into a number of separate files using awk.

Needed software

  • ASCII editor
  • awk.exe (included by default on Linux)

Example

Split the sieve file t16_b999.prp into 4 separate files.

Preparation WIN

  • Copy gawk.exe in a folder
  • Create a file named split.awk with this code:
BEGIN {getline line; i=1}
{
  if (head[i] == 0)
  {
    print line >>i".txt"
    head[i]=1
  }
  print $0 >>i".txt"
  i++
  if (i==files+1) i=1
}
  • Copy the sieve file in this folder (for example t16_b999.prp).
  • Call gawk -f split.awk files=4 t16_b999.prp.

Results:

  • Creates 4 files 1.txt to 4.txt with equally split candidates sorted by n.

Preparation LINUX

  • awk is probably already present on your computer.
  • Create a file named split.awk with the same code as above.
  • Copy the sieve file in this folder (for example t16_b999.prp).
  • Call awk -f split.awk files=4 t16_b999.prp.

Results:

  • Creates 4 files 1.txt to 4.txt with equally split candidates sorted by n.