DreamSeller92

auctionator_excell

May 8th, 2021 (edited)
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. from __future__ import print_function
  2.  
  3. import os
  4. import os.path
  5. import pandas as pd
  6. from templates.auc_scan_data import DATABASE
  7.  
  8. def main_data_from_lua():
  9.  
  10.     wow_auction_db = f'C:\Games\Sirus\WTF\Account\ACCOUNTNAME\SavedVariables\Auctionator.lua'
  11.     file_auc_db = os.path.abspath(wow_auction_db )
  12.     with open(file_auc_db, 'r', encoding='utf-8') as f:
  13.         bd_line = ''
  14.         for line in f:
  15.             bd_line += line
  16.  
  17.     # Убираем мусор и создаем готовый к записи файл
  18.     AUC_price_db = bd_line.split('AUCTIONATOR_PRICE_')[1].split('AUCTIONATOR_LAST_SCAN_TIME')[0]
  19.     AUC_price_db = AUC_price_db.replace('=', ':').replace('[', '').replace(']','')
  20.     name_var, data_var = AUC_price_db[:8], AUC_price_db[10:]
  21.     AUC_price_db = name_var + "=" + data_var
  22.     with open( 'templates/auc_scan_data.py', 'w', encoding='utf-8' ) as f:
  23.          f.write(AUC_price_db)
  24.     main_data = DATABASE["Algalon x4 - 3.3.5a_Horde"]
  25.     for item in main_data.keys():
  26.         if type(main_data[item]) == dict:
  27.             main_data[item] = main_data[item]['mr']
  28.         main_data[item] = main_data[item]/10000
  29.     df_main_data = pd.DataFrame.from_dict ( main_data, orient='index' )
  30.     df_main_data.to_excel ( 'auc_data.xlsx', sheet_name='aux' )
Add Comment
Please, Sign In to add comment