Skip to content

Commit 559b035

Browse files
task
1 parent 633e1bd commit 559b035

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

Task/output/table_0.csv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Catalog Number,Model No.,Description,RPM,Voltage (V),Frequency (Hz),Phase,Amp Draw (A),Power,Weight,
2+
,,,,,,,,,kg,lb.
3+
41935,700,700 Power Drive,26-30,115,50 - 60,1,13,-,25.0,11.0
4+
41940,700,700 Power Drive,28,230,50 - 60,1,6,-,25.0,11.0
5+
46832,700,700 Power Drive Only,28,115,50 - 60,1,13,-,30.8,14.0
6+
12651,700,700 Power Drive Only,28,230,50 - 60,1,6,-,30.8,14.0
7+
69170,700,700 Power Drive,28,230,50 - 60,1,6,-,25.0,11.0
8+
45178,700,"700 Power Drive w/ 1/2""-2"" NPT Die Heads, Case and Support Arm",28,115,50 - 60,1,13,-,-,-

Task/output/table_1.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Catalog Number,Model No.,Description,Weight,
2+
,,,kg,lb.
3+
10883,418,Oiler with One Gallon Premium Thread Cutting Oil,20.5,9.4
4+
73442,418,418 Oiler,20.5,9.4
5+
42600,770,770 Adapter for 00-R and 00-RB,4.4,2.0
6+
42605,771,771 Adapter for 0-R,4.4,2.0
7+
42610,772,772 Adapter for 11-R and R-200 (1/8''- 1 1/4''),4.4,2.0
8+
42615,773,773 Adapter for 111-R,2.2,1.0
9+
42620,774,"774 Square Drive Adapter - 15/16""",4.4,2.0
10+
42625,775,775 Support Arm for No. 700,11.0,5.0
11+
42950,B-171-X,B-171-X Metal Carrying Case,28.8,13.0
12+
41620,-,Gearhead Motor Grease,1.1,0.5

Task/output/table_2.csv

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Catalog Number,Description
2+
37825,12R ½” NPT DIES
3+
37830,12R 3/4” NPT DIES
4+
37835,12R 1” NPT DIES
5+
37840,12R 1-1/4” NPT DIES
6+
37845,12R 1-1/2” NPT DIES
7+
37850,12R 2” NPT DIES
8+
37870,12R ½” NPT HIGH SPEED DIES
9+
37875,12R 3/4” HIGH SPEED NPT DIES
10+
37880,12R 1” NPT HIGH SPEED DIES
11+
37885,12R 1-1/4” HIGH SPEED NPT DIES
12+
37890,12R 1-1/2” HIGH SPEED NPT DIES
13+
37895,12R 2” NPT HIGH SPEED DIES
14+
36890R,"1/2"" NPT 00-R Die Head"
15+
36895,"3/4"" NPT 00-R Die Head"
16+
36900,"1"" NPT 00-R Die Head"
17+
37390,"1/2"" NPT 12-R Die Head"
18+
37395,"3/4"" NPT 12-R Die Head"
19+
37400,"1"" NPT 12-R Die Head"
20+
37405,"1-1/4"" NPT 12-R Die Head"
21+
37410,"1-1/2"" NPT 12-R Die Head"
22+
37415,"2"" NPT 12-R Die Head"
23+
37490,"12R 1"" NPT HIGH SPEED COMPLETE DIE HEAD"
24+
37505,"12R 2"" NPT HIGH SPEED COMPLETE DIE HEAD"

Task/table2csv.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
import requests, os
3+
import pandas as pd
4+
from bs4 import BeautifulSoup
5+
6+
try: os.mkdir('output')
7+
except: pass
8+
9+
link = 'https://www.ridgid.com/in/en/700-power-drive'
10+
11+
req = requests.get(link)
12+
soup = BeautifulSoup(req.content, 'html5lib')
13+
14+
table = soup.findAll('table',
15+
attrs = {
16+
'class':'table-overflow productTable'
17+
}
18+
)
19+
20+
for ind, tab in enumerate(table):
21+
tr = tab.findAll('tr')
22+
row_list = {}
23+
counter = 0
24+
25+
for row in tr:
26+
co_list = []
27+
28+
for i in row:
29+
co_list.append(i.text.strip())
30+
31+
co_list = [x for x in co_list if x not in ['']]
32+
if ind != 2: # this condition is to handle nested row for (WEIGHT LB KG)
33+
34+
if counter == 0:
35+
length = len(co_list)
36+
37+
if counter == 1:
38+
for _ in range(length):
39+
co_list.append('')
40+
41+
co_list.pop()
42+
co_list = co_list[::-1]
43+
44+
row_list.update({counter : co_list})
45+
counter += 1
46+
47+
df = pd.DataFrame.from_dict(row_list, orient='index')
48+
df.to_csv(f'output/table_{ind}.csv', header=False, index=False)

Task/table2csv.zip

1.84 KB
Binary file not shown.

0 commit comments

Comments
 (0)