0

I'm trying to automate an email sending service which sends a person's bus station to his mail. In order to do so I need to pull some data from a Hebrew website.

I need to append to a list from the same website but from a different tab/page (I managed to pull the first page), and then to write the data to a CSV file.

I managed to pull the first page to a data frame list:

import requests
import pandas as pd
import csv

url = 'http://yit.maya-tour.co.il/yit-pass/Drop_Report.aspx? 
       client_code=2660&coordinator_code=2669'
html = requests.get(url).text
df_list = pd.read_html(html)
print(df_list)
myFile = open('my data.csv', 'wb')
wr = csv.writer(myFile, quoting=csv.QUOTE_ALL)
wr.writerow(df_list)

i can't find a way to write to file, as I get the message: "TypeError: a bytes-like object is required, not 'str'"

I expect to get the full list from multiple pages and then to write to CSV.

aschultz
  • 1,658
  • 3
  • 20
  • 30
matanslook
  • 53
  • 4

1 Answers1

0

I think you should use 'w' instead of 'wb' as an option on open(). The 'b' makes the command expect a binary object. Like this:

myFile = open('my data.csv', 'w')

See this link for more info

Tepexic
  • 21
  • 4
  • It did helped and stop having the error, but it writes to the file weird stuff, like it has a problem with hebrew. Even though i can see the data printed in Hebrew in the terminal – matanslook Aug 20 '19 at 17:08