Whale-Green
Unlock high-converting offers & powerful promotion tools. Follow the whale to affiliate success!

PropellerAds [traffic history]

Exclusive mVAS offers here

Alukard_X

Grand Guru
Joined
Oct 3, 2020
Messages
795
1755198964693-png.68361

1755198969911-png.68362

Python:
import  os
import zipfile
from datetime import datetime
import pandas  as pd

# Folder containing ZIP files
folder_path  = r'/home/user/files'

# List of CSV filenames  inside ZIPs
csv_files = [
     'Propellerads_desktop_mac.csv',
    'Propellerads_desktop_windows.csv',
     'Propellerads_mobile_android.csv',
     'Propellerads_mobile_ios.csv'
]

# List of columns to  remove from final DataFrame
columns_to_drop = ['B1',  'B2', 'B3', 'B4', 'B5']

# Initialize an  empty list to collect dataframes
all_data =  []

# List all ZIP files in  the folder
zip_files = [f for f  in os.listdir(folder_path) if f.endswith('.zip')]

for zip_filename in  zip_files:
    zip_path =  os.path.join(folder_path, zip_filename)
    with  zipfile.ZipFile(zip_path, 'r') as zip_ref:
         for  csv_name in csv_files:
              try:
                   info = zip_ref.getinfo(csv_name)
                   # Extract date from info.date_time tuple
                   csv_date = datetime(*info.date_time).date()
              except  KeyError:
                  # CSV  file not found in ZIP
                   continue  # Skip  if not present
              
              # Read CSV data  from ZIP with flexible delimiter
              df =  None
              for delimiter in [',', ';']:
                   try:
                       with zip_ref.open(csv_name)  as file:
                            df_candidate = pd.read_csv(file, delimiter=delimiter)
                            # Check  for required columns
                            if 'COUNTRY_CODE' in df_candidate.columns  and 'TRAFFIC' in df_candidate.columns:
                                 df = df_candidate
                                 break  # Successfully read  with this delimiter
                   except Exception as e:
                       #  Could log error here if needed
                        continue
              if df is not None:
                   # Assign date  from file modification timestamp
                   df['Date'] = pd.to_datetime(csv_date)
 

Attachments

  • traffic_pivot.zip
    2.1 MB · Views: 39
  • traffic_trends.zip
    3.2 MB · Views: 54
To view the premium content in our affiliate marketing forum (including this awesome thread), you must first register and upgrade your account. Register today and become a part of our amazing community!
Top