Quick push.

This commit is contained in:
Phil Bajsicki 2023-08-23 17:02:15 +02:00
parent 3a7923177d
commit 11683ae175
5 changed files with 3002 additions and 2852 deletions

View file

@ -260,7 +260,8 @@ cp ./mod-recipes/recipes-all-sorted-product.csv ./mod-recipes/intermediate.csv
From here on, all changes will take place on the basis of the ~intermediate.csv~ file, and outputs will be directed to ~output.csv~. This will prevent time loss in case of a mistyped command.
*** Define raw ingredients by their category
We have the following categories we'll be assigning:
**** We have the following categories we'll be assigning:
- Telescoping, (inserters, belts, things that reach)
- Metalworking,
- Plastic,
@ -285,13 +286,87 @@ To do this, we'll start with something like this:
open(my $in, "<", "./mod-recipes/intermediate.csv") or die "Can't open intermediates.csv";
open(my $out, ">", "./mod-recipes/output.csv") or die "Can't open output.csv";
my @patterns = (
# 0 metal
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 1 wood
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 2 plastic
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 3 electronics
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 4 glass
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 5 stone
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/");
while (<$in>) {
@line = split(",", $_);
if ($line[1] =~ /(iron|steel|copper|zinc|tungsten|titanium|tin|nickel|silver|platinum|manganese|lead|gold|aluminium)/) {
$line[0] = 'metal'
if ($line[1] =~ "$patterns[0]") {
print $out "metal @line";
}
my $lineout = join (',', @line);
print $out "$lineout";
if ($line[1] =~ "$patterns[1]") {
print $out "wood @line";
}
if ($line[1] =~ "$patterns[2]") {
print $out "plastic @line";
}
if ($line[1] =~ "$patterns[3]") {
print $out "electronics @line";
}
if ($line[1] =~ "$patterns[4]") {
print $out "glass @line";
}
if ($line[1] =~ "$patterns[5]") {
print $out "stone @line";
}
else {
print $out "@line";
}
}
}
close $in or die "$in: $!";
close $out or die "$out: $!";

82
fra.pl
View file

@ -1,13 +1,87 @@
open(my $in, "<", "./mod-recipes/intermediate.csv") or die "Can't open intermediates.csv";
open(my $out, ">", "./mod-recipes/output.csv") or die "Can't open output.csv";
my @patterns = (
# 0 metal
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 1 wood
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 2 plastic
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 3 electronics
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 4 glass
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/",
# 5 stone
"m/[\-?,?s*]
(bronze|iron|steel|copper|\
zinc| tungsten|titanium|tin|\
nickel|silver|platinum|manganese|\
lead|gold|aluminium|aluminum)\
[\-?,?\s*]/");
while (<$in>) {
@line = split(",", $_);
if ($line[1] =~ /(iron|steel|copper|zinc|tungsten|titanium|tin|nickel|silver|platinum|manganese|lead|gold|aluminium)/) {
$line[0] = 'metal'
if ($line[1] =~ "$patterns[0]") {
print $out "metal @line";
}
my $lineout = join (',', @line);
print $out "$lineout";
if ($line[1] =~ "$patterns[1]") {
print $out "wood @line";
}
if ($line[1] =~ "$patterns[2]") {
print $out "plastic @line";
}
if ($line[1] =~ "$patterns[3]") {
print $out "electronics @line";
}
if ($line[1] =~ "$patterns[4]") {
print $out "glass @line";
}
if ($line[1] =~ "$patterns[5]") {
print $out "stone @line";
}
else {
print $out "@line";
}
}
}
close $in or die "$in: $!";
close $out or die "$out: $!";

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file