I have the following table in a txt file:
|Client | Container weight | Country of Origin | Product code ||S4378 | 450 Ton | China | 457841 || | 350 Ton | Japan | 457841 || | 900 Ton | Japan | 457841 || | 589 Ton | China | 457841 ||S4978 | 1400 Ton | Mexico | 457841 || | 980 Ton | Emirates | 457841 || | 550 Ton | China | 457841 ||S4578 | 450 Ton | China | 457841 |
The table starts in Line 81.
I want to create an output text file as follows:
|Client | Container weight | Country of Origin | Product code ||S4378 | 450 Ton | China | 457841 ||S4378 | 350 Ton | Japan | 457841 ||S4378 | 900 Ton | Japan | 457841 ||S4378 | 589 Ton | China | 457841 ||S4978 | 1400 Ton | Mexico | 457841 ||S4978 | 980 Ton | Emirates | 457841 ||S4978 | 550 Ton | China | 457841 ||S4578 | 450 Ton | China | 457841 |
I have tried extracting lines:
file = open('containers.txt')
lines_to_print = [80, 81, 82, 83, 84, 85...]
for index, line in enumerate(file):if index in lines_to_print:print(line)
My question is how do I write this code, if my table has 300 rows?