Advertisement
efoxxi

show_info.py

Dec 26th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. import csv
  2. from csv import writer as csvwriter
  3.  
  4. import shutil
  5. import datetime
  6. import os
  7. import btce
  8. from time import strftime, localtime
  9.  
  10.  
  11. localtime2 = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  12. info = btce.getinfo()
  13.  
  14. infilename = 'z_finance.csv'
  15. outfilename = 'finance_temp.csv'
  16.  
  17. receive_data = 1
  18.  
  19. print "Funds:",
  20. csv_arr = [localtime2]
  21. for currency in ['USD', 'BTC', 'LTC', 'EUR', 'RUR', 'NMC']:
  22.     finance_info = info['funds'][currency.lower()]
  23.     csv_arr.append(finance_info)
  24.     print finance_info,
  25. print
  26.  
  27.  
  28. with open(infilename) as infile:
  29.     csvr = csv.reader(infile)
  30.     with open(outfilename, 'wb') as outfile:
  31.         csvw = csvwriter(outfile)
  32.         counter = 0
  33.         for row in csvr:
  34.             csvw.writerow(row)
  35.             counter += 1
  36.         if counter != 0:
  37.             if row[1] == str(csv_arr[1]) and row[2] == str(csv_arr[2]) and row[3] == str(csv_arr[3]) and row[4] == str(csv_arr[4]) and row[5] == str(csv_arr[5]) and row[6] == str(csv_arr[6]):
  38.                 print 'no changes in csv'
  39.             else:
  40.                 csvw.writerow(csv_arr)
  41.         else:
  42.             csvw.writerow(csv_arr)
  43.  
  44. if receive_data == 1:
  45.     #os.remove(infilename)
  46.     #os.rename(outfilename, infilename)
  47.     shutil.copy2(outfilename, infilename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement