第1列中的值搜索表,并在同一行的列2中打印数据

时间:2017-10-03 10:57:47

标签: python mysql bash awk sed

我已尽力找到这个 - grep,awk,sed - 我想在linux shell,javaScript或python中做这个(或者其他什么,但我知道那3个最好的)。我发布的代码是JavaScript(我最喜欢的),但是我愿意接受几乎所有的答案 - 地狱,我会学习一门新语言,或者在Scratch中做它,如果它让我不能写一些bajillion线...

我有一组齿轮箱的扭矩值列表及其相应的ID号(为了简化,我使用了圆形数字 - 左侧的扭矩值和右侧的零件号):

maxTorq:Unit ID#
100:6100
200:6105
300:6110
.......and this goes for HUNDREDS of lines.....
99990:6985
100000:6990

我目前的代码是简单的重复" if ... else if"声明.. 这里是! (运行它,它不太蹩脚......需要更多的CSS,在我的网站上它有一些很酷的图形和样式。)

    <!DOCTYPE html>
<html lang="en">
<style>
body {
    background-image: url("../media/sumi.jpeg");
    background-repeat: no-repeat;
    background-position: right top;
}
#main {
  max-width: 800px;
  margin: 20px auto; 
  border: solid;
  background: #87CEEB;
  padding: 50px;
  position: relative; 
}
#answer {
  max-width: 200px;
  margin: 20px auto; 
  border: solid;
  background: #FFEFD5;
  padding: 50px;
  position: relative;
  padding: 10px;
  right: 300px; 
}
</style>

<body>
<head>
    <meta charset="utf-8">
    <title>Sumitomo Sizer</title><br>

</head>
<body>
<h6> here it is:
<h1><b>Sumitomo Cyclo sizer!!</b></h1>
<div id="main">
<P> I am only showing 8 of the 18 available ratios.  Sure, you might need       the others for some reason, but you can do most things with these 8.</p>

<p>  What output speed is closest AND OVER what you need:
  <select id="vara">
<option value="11">159 RPM (11:1)</option>
<option value="17">103 RPM (17:1)</option>
<option value="29">60 RPM (29:1)</option>
<option value="35">50 RPM (35:1)</option>
<option value="43">40 RPM (43:1)</option>
<option value="59">30 RPM (59:1</option>
<option value="71">25 RPM (71:1)</option>
<option value="87">20 RPM (87:1)</option>
</select>
</p>

<P>What is your motor Horsepower @1750:
   <select id="varb">
<option value="0.5">1/2</option>
<option value="1">1</option>
<option value="1.5">1-1/2</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7.5">7.5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
</p>
<p>belt drive ratio: 
<input id="varc" type="text" value="1"/>:1
</p>
<P>Input style:
   <select id="vard">
<option value="0">Standard</option>
<option value="1">Top motor mount</option>
<option value="2">C-face (w/coupling)</option>
</select>
</p>
<p>Click the button to get your Sumitomo size</p>

<button onclick="sumisize()">Find it</button>
</p>
<div id="answer">
Sumitomo part number: <h2><p id="resultd"></h2></p><p id="resulta"></p>
Actual output speed: <p id="resultb"> </p>
Torque in inch-lbs.:<p id="resultc"></p>
</div>
<script type="text/javascript" language="javascript" charset="utf-8">

function sumisize()
{
var y = (document.getElementById('vara').value);
var v = (document.getElementById('varb').value);
var u = (document.getElementById('varc').value);
var q = (document.getElementById('vard').value);
var w=(v*36);
var t=(w*u);
var s=(t*y);
var r=((1750/u)/y);
var x="";
var z=(y);
var p=(q);
var o="";
var n="";
var m="";

if (p>0 && v==0.5)
  {
  m="-56"
  }
else if (p>0 && v==1)
  {
  m="-143"
  }
else if (p>0 && v==1.5)
  {
  m="-145"
  }
else if (p>0 && v==2)
  {
  m="-145"
  }
else if (p>0 && v==3)
  {
  m="-182"
  }
else if (p>0 && v==5)
  {
  m="-184"
  }
else if (p>0 && v==7.5)
  {
  m="-213"
  }
else if (p>0 && v==10)
  {
  m="-215"
  }
else if (p>0 && v==15)
  {
  m="-254"
  }
else if (p>0 && v==20)
  {
  m="-256"
  }
if (p==0)
  {
  o="CHH";
  }
else if (p==1)
  {
  o="CHHP";
  }
else if (p==2 && u==1)
  {
  o="CHHJ";
  }
else 
  {
  n=" Please Set 'Belt Drive Ratio' to 1 ";
  }
if (z==11 && s<=298)
  {
  x="-6080-Y11";
  }
else if (z==11 && s<=393)
  {
  x="-6085-Y11";
  }
else if (z==11 && s<=579)
  {
  x="-6090-Y11";
  }
else if (z==11 && s<=765)
  {
  x="-6095-Y11";
  }
else if (z==11 && s<=1190)
  {
  x="-6100-Y11";
  }
else if (z==11 && s<=1610)
  {
  x="-6105-Y11";
  }
else if (z==11 && s<=1790)
  {
  x="-6110-Y11";
  }
else if (z==11 && s<=1970)
  {
  x="-6115-Y11";
  }
else if (z==11 && s<=2560)
  {
  x="-6120-Y11";
  }
else if (z==11 && s<=2990)
  {
  x="-6125-Y11";
  }
else if (z==11 && s<=4730)
  {
  x="-6130-Y11";
  }
else if (z==11 && s<=5700)
  {
  x="-6135-Y11";
  }
else if (z==11 && s<=6570)
  {
  x="-6140-Y11";
  }
else if (z==11 && s<=7650)
  {
  x="-6145-Y11";
  }
else if (z==11 && s<=9900)
  {
  x="-6160-Y11";
  }
else if (z==17 && s<=408)
  {
  x="-6080-Y17";
  }
else if (z==17 && s<=536)
  {
  x="-6085-Y17";
  }
else if (z==17 && s<=788)
  {
  x="-6090-Y17";
  }
else if (z==17 && s<=1040)
  {
  x="-6095-Y17";
  }
else if (z==17 && s<=1620)
  {
  x="-6100-Y17";
  }
else if (z==17 && s<=2190)
  {
  x="-6105-Y17";
  }
else if (z==17 && s<=2440)
  {
  x="-6110-Y17";
  }
else if (z==17 && s<=2680)
  {
  x="-6115-Y17";
  }
else if (z==17 && s<=3490)
  {
  x="-6120-Y17";
  }
else if (z==17 && s<=4070)
  {
  x="-6125-Y17";
  }
else if (z==17 && s<=5360)
  {
  x="-6130-Y17";
  }
else if (z==17  && s<=6160)
  {
  x="-6135-Y17"
  }
else if (z==17  && s<=8250)
  {
  x="-6140-Y17"
  }
else if (z==17  && s<=9370)
  {
  x="-6145-Y17"
  }
else if (z==17  && s<=10200)
  {
  x="-6160-Y17"
  }
else if (z==17  && s<=14700)
  {
  x="-6165-Y17"
  }
else if (z==29 && s<=621)
  {
  x="-6085-Y29";
  }
else if (z==29 && s<=832)
  {
  x="-6090-Y29";
  }
else if (z==29 && s<=1040)
  {
  x="-6095-29";
  }
else if (z==29 && s<=1610)
  {
  x="-6100-Y29";
  }
else if (z==29 && s<=2120)
  {
  x="-6105-Y29";
  }
else if (z==29 && s<=2530)
  {
  x="-6110-29";
  }
else if (z==29 && s<=2950)
  {
  x="-6115-Y29";
  }
else if (z==29 && s<=3980)
  {
  x="-6120-Y29";
  }
else if (z==29 && s<=5010)
  {
  x="-6125-29";
  }
else if (z==29 && s<=5960)
  {
  x="-6130-Y29";
  }
else if (z==29 && s<=7500)
  {
  x="-6135-Y29";
  }
else if (z==29 && s<=7920)
  {
  x="-6140-29";
  }
else if (z==29 && s<=9980)
  {
  x="-6145-Y29";
  }
else if (z==29 && s<=14000)
  {
  x="-6160-Y29";
  }
else if (z==29 && s<=15200)
  {
  x="-6165-29";
  }
else if (z==29 && s<=19000)
  {
  x="-6170-Y29";
  }
else if (z==29 && s<=25000)
  {
  x="-6175-Y29";
  }
else if (z==35 && s<=981)
  {
  x="-6090-Y35";
  }
else if (z==35 && s<=1220)
  {
  x="-6095-Y35";
  }
else if (z==35 && s<=1560)
  {
  x="-6100-Y35";
  }
else if (z==35 && s<=1920)
  {
  x="-6105-Y35";
  }
else if (z==35 && s<=2410)
  {
  x="-6110-Y35";
  }
else if (z==35 && s<=2900)
  {
  x="-6115-Y35";
  }
else if (z==35 && s<=4010)
  {
  x="-6120-Y35";
  }
else if (z==35 && s<=5100)
  {
  x="-6125-Y35";
  }
else if (z==35 && s<=5950)
  {
  x="-6130-Y35";
  }
else if (z==35 && s<=6820)
  {
  x="-6135-Y35";
  }
else if (z==35 && s<=8360)
  {
  x="-6140-Y35";
  }
else if (z==35 && s<=12200)
  {
  x="-6145-Y35";
  }
else if (z==35 && s<=15500)
  {
  x="-6160-Y35";
  }
else if (z==35 && s<=18300)
  {
  x="-6165-Y35";
  }
else if (z==35 && s<=19300)
  {
  x="-6170-Y35";
  }
else if (z==35 && s<=24100)
  {
  x="-6175-Y35";
  }
else if (z==35 && s<=30200)
  {
  x="-6180-Y35";
  }
else if (z==43 && s<=858)
  {
  x="-6090-Y43";
  }
else if (z==43 && s<=1190)
  {
  x="-6095-Y43";
  }
else if (z==43 && s<=1540)
  {
  x="-6100-Y43";
  }
else if (z==43 && s<=2140)
  {
  x="-6105-Y43";
  }
else if (z==43 && s<=2570)
  {
  x="-6110-Y43";
  }
else if (z==43 && s<=2990)
  {
  x="-6115-Y43";
  }
else if (z==43 && s<=3780)
  {
  x="-6120-Y43";
  }
else if (z==43 && s<=4700)
  {
  x="-6125-Y43";
  }
else if (z==43 && s<=5910)
  {
  x="-6130-Y43";
  }
else if (z==43 && s<=7430)
  {
  x="-6135-Y43";
  }
else if (z==43 && s<=7780)
  {
  x="-6140-Y43";
  }
else if (z==43 && s<=10600)
  {
  x="-6145-Y43";
  }
else if (z==43 && s<=14700)
  {
  x="-6160-Y43";
  }
else if (z==43 && s<=15500)
  {
  x="-6165-Y43";
  }
else if (z==43 && s<=19200)
  {
  x="-6170-Y43";
  }
else if (z==43 && s<=22300)
  {
  x="-6175-Y43";
  }
else if (z==43 && s<=29800)
  {
  x="-6180-Y43";
  }
else if (z==43 && s<=37200)
  {
  x="-6185-Y43";
  }
else if (z==59 && s<=1010)
  {
  x="-6095-Y59";
  }
else if (z==59 && s<=1400)
  {
  x="-6100-Y59";
  }
else if (z==59 && s<=1920)
  {
  x="-6105-Y59";
  }
else if (z==59 && s<=2330)
  {
  x="-6110-Y59";
  }
else if (z==59 && s<=2730)
  {
  x="-6115-Y59";
  }
else if (z==59 && s<=3530)
  {
  x="-6120-Y59";
  }
else if (z==59 && s<=4380)
  {
  x="-6125-Y59";
  }
else if (z==59 && s<=5920)
  {
  x="-6130-Y59";
  }
else if (z==59 && s<=6830)
  {
  x="-6135-Y59";
  }
else if (z==59 && s<=8010)
  {
  x="-6140-Y59";
  }
else if (z==59 && s<=9900)
  {
  x="-6145-Y59";
  }
else if (z==59 && s<=12000)
  {
  x="-6160-Y59";
  }
else if (z==59 && s<=15500)
  {
  x="-6165-Y59";
  }
else if (z==59 && s<=19400)
  {
  x="-6170-Y59";
  }
else if (z==59 && s<=25500)
  {
  x="-6175-Y59";
  }
else if (z==59 && s<=26400)
  {
  x="-6180-Y59";
  }
else if (z==59 && s<=32500)
  {
  x="-6185-Y59";
  }
else if (z==59 && s<=41300)
  {
  x="-6190-Y59";
  }
else if (z==59 && s<=51000)
  {
  x="-6195-Y59";
  }
else if (z==71 && s<=1410)
  {
  x="-6100-Y71";
  }
else if (z==71 && s<=1830)
  {
  x="-6105-Y71";
  }
else if (z==71 && s<=2180)
  {
  x="-6110-Y71";
  }
else if (z==71 && s<=2470)
  {
  x="-6115-Y71";
  }
else if (z==71 && s<=3120)
  {
  x="-6120-Y71";
  }
else if (z==71 && s<=3910)
  {
  x="-6125-Y71";
  }
else if (z==71 && s<=5960)
  {
  x="-6130-Y71";
  }
else if (z==71 && s<=7070)
  {
  x="-6135-Y71";
  }
else if (z==71 && s<=7920)
  {
  x="-6140-Y71";
  }
else if (z==71 && s<=9810)
  {
  x="-6145-Y71";
  }
else if (z==71 && s<=11300)
  {
  x="-6160-Y71";
  }
else if (z==71 && s<=18400)
  {
  x="-6165-Y71";
  }
else if (z==71 && s<=19300)
  {
  x="-6170-Y71";
  }
else if (z==71 && s<=23300)
  {
  x="-6175-Y71";
  }
else if (z==71 && s<=28600)
  {
  x="-6180-Y71";
  }
else if (z==71 && s<=31900)
  {
  x="-6185-Y71";
  }
else if (z==71 && s<=44100)
  {
  x="-6190-Y71";
  }
else if (z==71 && s<=50800)
  {
  x="-6195-Y71";
  }
else if (z==87 && s<=1730)
  {
  x="-6100-Y87";
  }
else if (z==87 && s<=2260)
  {
  x="-6105-Y87";
  }
else if (z==87 && s<=2640)
  {
  x="-6110-Y87";
  }
else if (z==87 && s<=3030)
  {
  x="-6115-Y87";
  }
else if (z==87 && s<=3770)
  {
  x="-6120-Y87";
  }
else if (z==87 && s<=4510)
  {
  x="-6125-Y87";
  }
else if (z==87 && s<=5660)
  {
  x="-6130-Y87";
  }
else if (z==87 && s<=7620)
  {
  x="-6135-Y87";
  }
else if (z==87 && s<=7900)
  {
  x="-6140-Y87";
  }
else if (z==87 && s<=9900)
  {
  x="-6145-Y87";
  }
else if (z==87 && s<=13900)
  {
  x="-6160-Y87";
  }
else if (z==87 && s<=15500)
  {
  x="-6165-Y87";
  }
else if (z==87 && s<=19200)
  {
  x="-6170-Y87";
  }
else if (z==87 && s<=22500)
  {
  x="-6175-Y87";
  }
else if (z==87 && s<=28500)
  {
  x="-6180-Y87";
  }
else if (z==87 && s<=34200)
  {
  x="-6185-Y87";
  }
else if (z==87 && s<=47000)
  {
  x="-6190-Y87";
  }
else if (z==87 && s<=54400)
  {
  x="-6195-Y87";
  }
else if (z==87 && s<=63500)
  {
  x="-6205-Y87";
  }
else if (z==87 && s<=85400)
  {
  x="-6215-Y87";
  }
else
  {
  x="- stop and contact Jay at 601.583.2005"
  }
document.getElementById("resulta").innerHTML= o + x + m;
document.getElementById('resultb').innerHTML = Math.round(r) + " RPM";
document.getElementById("resultc").innerHTML= s;
document.getElementById("resultd").innerHTML= n;

}
</script>
Use this application at your own risk. Results are calculated based on the Cyclo 6000 series catalog information.  The information provided is for reference ONLY!! I do not make any claims the information is correct, viable, usable, safe or marketable.  YOU are responsible for insuring YOU select the correct speed reducer based on the literature and guidance of Sumitomo Machinery Corporation of America (or Japan)!

</center>
<div>
</body>
</html>

这很好,除了我在这种方法上投入了100个小时,我需要做5-6个比我刚做的更大的制造商。这只是一个制造商中的一条线,而且我只是通过证明它们提供的18种可能的比率中的8种来截断它以减少工作量...

我想要做的是为每个齿轮线创建一个2列表(例如开头的示例),并让计算机查看#1列,以便在列#1中找到一个大于它的值& #34; S&#34; (行#x,第1列)但不到&#34; s&#34;在下一行(行#y,列#1)并打印行#y列#2的数据。

似乎有一个简单的答案,我找不到它 - grep,awk,sed,SOMETHING,我错过了它......

2 个答案:

答案 0 :(得分:0)

我真的无法从你的问题中说出,无论你遇到什么问题,最好的办法是什么,而不是试图解决这个问题,而是更好的方式来写一系列if-else&#39; #39; ve posted可能是(在awk中):

split("298 393 579 765 1190 1610",nums)
for (i=1; i in nums; i++) {
    if (s < nums[i]) {
        x = "-" (6075 + i*5) "-Y" z
        break
    }
}

这只是为了让您了解一种不同的方式,您的代码可以更简单地编写,但在您的问题中没有更多信息,即使这可能是不必要的冗长,或者您可能需要使用{{1如果所有z值都具有相同的z比较或s输出。

答案 1 :(得分:0)

这在Awk中很简单。传入你想要比较的值(你可能在shell变量中有这个,但是在这个例子中,我是硬编码203)并从值等于的最后一行返回第二列或大于第一列中的数字。

awk -F : -v value="203" 'NR==1 { next }  # skip the silly header line
    value >= $1 { m=$2; next }
    { exit }  # done; fall through to END
    END { print m }' file

这显然假设输入文件在第一列上以单调递增的顺序排序,如您的示例所示。

-F :设置列分隔符(Awk中的默认值是任何空白行),-v value=whatever将Awk变量value设置为任意值。 (一个常见的新手误解是假设awk可以使用shell变量 - 它们不是.Awk基本上对调用程序一无所知,甚至不能假设它首先从shell调用。)

主要逻辑应该很容易理解 - 只要该值大于或等于第一列的数量,Awk一次读取一行并将m设置为第二列,然后跳过脚本的其余部分,然后从内存中的下一个输入行开始重新开始。当条件不再成立时,我们退出;当脚本退出时,我们打印从上一行捕获的值。 (退出是一个小优化;显然不需要读取文件的其余部分。)作为一些极端情况,我们跳过第一行(因为它包含标题,而不是实际数据)并应对掉落通过从END块进行打印而不仅仅是在我们实际遇到第一列实际上大于输入值的行时打印和退出文件的结尾。

如果在shell脚本中需要这个,那么只获取变量输出值的构造是

outputvalue=$(awk -F : -v value="$inputvalue" ....)

同样的逻辑显然也很容易在Python中实现。

import logging, sys

try:
    value = int(sys.argv[1])
except IndexError:
    logging.error('Syntax: {0} value'.format(sys.argv[0]))
    exit(123)

final = None
for line in sys.stdin:
    line = line.rstrip('\n')
    try:
        first, second = line.split(':')
    except ValueError:
        logging.warn('Invalid input {0}'.format(line))
        continue
    first = int(first)
    if value >= first:
        final = second
    else:
        break
print(final)

最后,这里是你的Javascript代码的重构版本(我希望)与更少的代码完全相同。我不是一个真正的JavaScript程序员,我没有尝试过多地清理代码,但我猜这样的东西是你实际想要的。

function sumisize()
{
var y = (document.getElementById('vara').value);
var v = (document.getElementById('varb').value);
var u = (document.getElementById('varc').value);
var q = (document.getElementById('vard').value);
var w=(v*36);
var t=(w*u);
var s=(t*y);
var r=((1750/u)/y);
var x="";
var z=(y);
var p=(q);
var o="";
var n="";
var m="";

var zvalues = {
    11: { 298: 6080,   393: 6085,   579: 6090,   765: 6095,  1190: 6100,
	 1610: 6105,  1790: 6110,  1970: 6115,  2560: 6120,  2990: 6125,
	 4730: 6130,  5700: 6135,  6570: 6140,  7650: 6145,  9900: 6160 },
    17: { 408: 6080,   536: 6085,   788: 6090,  1040: 6095,  1620: 6100,
	 2190: 6105,  2440: 6110,  2680: 6115,  3490: 6120,  4070: 6125,
         5360: 6130,  6160: 6135,  8250: 6140,  9370: 6145, 10200: 6160,
	14700: 6165 },
    29: { 621: 6085,   832: 6090,  1040: 6095,  1610: 6100,  2120: 6105,
	 2530: 6110,  2950: 6115,  3980: 6120,  5010: 6125,  5960: 6130,
	 7500: 6135,  7920: 6140,  9980: 6145, 14000: 6160, 15200: 6165,
	19000: 6170, 25000: 6175 },
    35: { 981: 6090,  1220: 6095,  1560: 6100,  1920: 6105,  2410: 6110,
	 2900: 6115,  4010: 6120,  5100: 6125,  5950: 6130,  6820: 6135,
	 8360: 6140, 12200: 6145, 15500: 6160, 18300: 6165, 19300: 6170,
	24100: 6175, 30200: 6180 },
    43: { 858: 6090,  1190: 6095,  1540: 6100,  2140: 6105,  2570: 6110,
	 2990: 6115,  3780: 6120,  4700: 6125,	5910: 6130,  7430: 6135,
	 7780: 6140, 10600: 6145, 14700: 6160, 15500: 6165, 19200: 6170,
	22300: 6175, 29800: 6180, 37200: 6185 },
    59: {1010: 6095,  1400: 6100,  1920: 6105,  2330: 6110,  2730: 6115,
	 3530: 6120,  4380: 6125,  5920: 6130,  6830: 6135,  8010: 6140,
	 9900: 6145, 12000: 6160, 15500: 6165, 19400: 6170, 25500: 6175,
	26400: 6180, 32500: 6185, 41300: 6190, 51000: 6195 },
    71: {1410: 6100,  1830: 6105,  2180: 6110,	2470: 6115,  3120: 6120,
	 3910: 6125,  5960: 6130,  7070: 6135,  7920: 6140,  9810: 6145,
	11300: 6160, 18400: 6165, 19300: 6170, 23300: 6175, 28600: 6180,
	31900: 6185, 44100: 6190, 50800: 6195 },
    87: {1730: 6100,  2260: 6105,  2640: 6110,  3030: 6115,  3770: 6120,
	 4510: 6125,  5660: 6130,  7620: 6135,  7900: 6140,  9900: 6145,
	13900: 6160, 15500: 6165, 19200: 6170, 22500: 6175, 28500: 6180,
	34200: 6185, 47000: 6190, 54400: 6195, 63500: 6205, 85400: 6215 }
};

var mvalues = { 0.5:  -56,  1.0: -143,  1.5: -145,  2.0: -145,  3.0: -182,
		5.0: -184,  7.5: -213, 10.0: -215, 15.0: -254, 20.0: -256 };

if (p>0) {
    m=mvalues[v];
}

if (p==0)
  {
  o="CHH";
  }
else if (p==1)
  {
  o="CHHP";
  }
else if (p==2 && u==1)
  {
  o="CHHJ";
  }
else 
  {
  n=" Please Set 'Belt Drive Ratio' to 1 ";
  }
 
    var smax = -1;
    var diag = "diagnostics: "
    for (var k in zvalues[z]) {
	diag += "k(" + k + ")<=s(" + s + ")? "
	if (k<=s && k>smax) {
	    diag += "k>smax(" + smax + "); dv=" + zvalues[z][k] + ". "
	      smax = k;
	      dv = zvalues[z][k];
	  }
    }
    diag += " Final smax = " + smax
    if (smax > -1)
    {
	x="-" + dv + "-Y" + z;
    }
else
  {
  x="- stop and contact Jay at 601.583.2005" + diag
  }
document.getElementById("resulta").innerHTML= o + x + m;
document.getElementById('resultb').innerHTML = Math.round(r) + " RPM";
document.getElementById("resultc").innerHTML= s;
document.getElementById("resultd").innerHTML= n;

}
body {
    background-image: url("../media/sumi.jpeg");
    background-repeat: no-repeat;
    background-position: right top;
}
#main {
  max-width: 800px;
  margin: 20px auto; 
  border: solid;
  background: #87CEEB;
  padding: 50px;
  position: relative; 
}
/*
#answer {
  max-width: 200px;
  margin: 20px auto; 
  border: solid;
  background: #FFEFD5;
  padding: 50px;
  position: relative;
  padding: 10px;
  right: 300px; 
}*/
<!DOCTYPE html>
<html lang="en">
<body>
<head>
    <meta charset="utf-8">
    <title>Sumitomo Sizer</title><br>
</head>
<body>
<h6> here it is:
<h1><b>Sumitomo Cyclo sizer!!</b></h1>
<div id="main">
<P> I am only showing 8 of the 18 available ratios.  Sure, you might need       the others for some reason, but you can do most things with these 8.</p>

<p>  What output speed is closest AND OVER what you need:
  <select id="vara">
<option value="11">159 RPM (11:1)</option>
<option value="17">103 RPM (17:1)</option>
<option value="29">60 RPM (29:1)</option>
<option value="35">50 RPM (35:1)</option>
<option value="43">40 RPM (43:1)</option>
<option value="59">30 RPM (59:1</option>
<option value="71">25 RPM (71:1)</option>
<option value="87">20 RPM (87:1)</option>
</select>
</p>

<P>What is your motor Horsepower @1750:
   <select id="varb">
<option value="0.5">1/2</option>
<option value="1">1</option>
<option value="1.5">1-1/2</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="5">5</option>
<option value="7.5">7.5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
</p>
<p>belt drive ratio: 
<input id="varc" type="text" value="1"/>:1
</p>
<P>Input style:
   <select id="vard">
<option value="0">Standard</option>
<option value="1">Top motor mount</option>
<option value="2">C-face (w/coupling)</option>
</select>
</p>
<p>Click the button to get your Sumitomo size</p>

<button onclick="sumisize()">Find it</button>
</p>
<div id="answer">
Sumitomo part number: <h2><p id="resultd"></h2></p><p id="resulta"></p>
Actual output speed: <p id="resultb"> </p>
Torque in inch-lbs.:<p id="resultc"></p>
</div>

Use this application at your own risk. Results are calculated based on the Cyclo 6000 series catalog information.  The information provided is for reference ONLY!! I do not make any claims the information is correct, viable, usable, safe or marketable.  YOU are responsible for insuring YOU select the correct speed reducer based on the literature and guidance of Sumitomo Machinery Corporation of America (or Japan)!

</center>
<div>
</body>
</html>