0

I already know how to read from txt file with 2 columns. But, I don't know how to read if the txt file is excel.

This is myfile.txt:

1   8
2   15
3   125
0   12
54  0
15  125
54  54
15  25
485 78

This is code if I used the txt file for python read:

import requests
with open("myfile.txt", "r") as a_file:
   for line in a_file:
      values = line.rstrip().split()
      CurrentRow = int(values[0]), int(values[1]) # << -----
      url = "url"
      headers = {headers}
      data = {"MyPayload": f"Will-be{CurrentRow[0]}-is{CurrentRow[1]}-ndwiqb"}
      Hasil = requests.post(url, headers=headers, data=data)

What the extra code if the file is excel with sheet name "Sheet 1"?

clikafns
  • 3
  • 5
  • This is a misconception: "if the [text] file is Excel..." Excel is a proprietary format closer to XML than to CSV or a plain text file. Look at `openpyxl` or `xlrd` or similar modules for reading Excel files. – mechanical_meat Aug 21 '21 at 15:51

0 Answers0