Важное сообщение
import pandas as pd
import requests
from requests.auth import HTTPBasicAuth
import gzip
from io import BytesIO
generate_dates = pd.date_range('2024-01-01', periods=30).tolist()
datelist = []
for date in generate_dates:
date = date.strftime('%Y-%m-%d')
datelist.append(date)
print(datelist)
for date in datelist:
res = requests.get(f"https://files.adriver.ru/your_login.ftp/{date}.logsite.csv.gz",
auth=HTTPBasicAuth('your_login', 'your_password'))
compressed_content = res.content
compressed_data = BytesIO(compressed_content)
with gzip.GzipFile(fileobj=compressed_data, mode='rb') as decompressed_data:
decompressed_content = decompressed_data.read()
with open('files/example.csv', 'wb') as f:
f.write(decompressed_content)
with ad_group_table as (
select user_id_ad_group,
groupArray(event_datetime) as group_event_datetime,
groupArray(event_date) as group_event_date,
groupArray(banner_id) as group_banner_id,
groupArray(domain) as group_domain
from (
select if(user_id = '0', hex(SHA1(concat(user_ip, user_agent))), user_id) as user_id_ad_group,
datetime as event_datetime,
date as event_date,
banner_id,
domain
from ADRIVER_AD
order by all)
group by user_id_ad_group),