-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-switzerland.py
45 lines (40 loc) · 1.31 KB
/
main-switzerland.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import time
import pandas as pd
from hotel_data import getDataFromHotel
# Create lists to store data for each column
column_a = []
column_b = []
column_c = []
# Open the text file for reading
with open('germany-numbers-3.txt', 'r') as file:
# Iterate over each line in the file
cnt = 0
for line in file:
# Print the current line to the console
# print(line.strip()) # .strip() removes the newline character at the end
url = 'https://www.tagungshotel.com/home.php?Kundenid=' + line.strip()
cnt += 1
print(cnt)
print(url)
# Wait for 1 second before proceeding to the next line
# time.sleep(1)
hotel_data = getDataFromHotel(url)
# Populate lists with JSON data
for section, section_data in hotel_data.items():
column_a.append(section) # Append section name only once
for key, value in section_data.items():
column_a.append('')
column_b.append(key)
column_c.append(value)
column_a.pop()
column_a.append('')
column_b.append('')
column_c.append('')
# Create DataFrame
df = pd.DataFrame({
'Column A': column_a,
'Column B': column_b,
'Column C': column_c
})
# Write DataFrame to Excel
df.to_excel('germany-3.xlsx', index=False)