Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- from csv import writer as csvwriter
- import shutil
- import datetime
- import os
- import btce
- from time import strftime, localtime
- localtime2 = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- info = btce.getinfo()
- infilename = 'z_finance.csv'
- outfilename = 'finance_temp.csv'
- receive_data = 1
- print "Funds:",
- csv_arr = [localtime2]
- for currency in ['USD', 'BTC', 'LTC', 'EUR', 'RUR', 'NMC']:
- finance_info = info['funds'][currency.lower()]
- csv_arr.append(finance_info)
- print finance_info,
- print
- with open(infilename) as infile:
- csvr = csv.reader(infile)
- with open(outfilename, 'wb') as outfile:
- csvw = csvwriter(outfile)
- counter = 0
- for row in csvr:
- csvw.writerow(row)
- counter += 1
- if counter != 0:
- 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]):
- print 'no changes in csv'
- else:
- csvw.writerow(csv_arr)
- else:
- csvw.writerow(csv_arr)
- if receive_data == 1:
- #os.remove(infilename)
- #os.rename(outfilename, infilename)
- shutil.copy2(outfilename, infilename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement