Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import io
  2. import datetime
  3.  
  4.  
  5. #from: fAdjustLog.txt
  6. """
  7. 06/11/2019 IND - Ibovespa Z19 109.091 108.876 -215 215,00
  8. 05/11/2019 IND - Ibovespa Z19 109.228 109.091 -137 137,00
  9. [...]
  10. """
  11.  
  12. #to: adjLogValuesStrip.txt
  13. """
  14. 108876,
  15. 109091,
  16. [...]
  17. """
  18. #and to: adjLogDatesStrip.txt
  19. """
  20.  
  21. "11/06/2019",
  22. "11/05/2019",
  23. [...]
  24.  
  25. """
  26.  
  27. fDates = io.open("adjLogDatesStrip.txt","wt")
  28. fValues = io.open("adjLogValuesStrip.txt", "wt")
  29. fAdjustLog = io.open("fAdjustLog.txt","rt")
  30.  
  31. tempLines = fAdjustLog.readlines()
  32. tempDates = []
  33. tempValues = []
  34.  
  35. for tempLine in tempLines:
  36.     tempDate = datetime.datetime.strptime(tempLine.split()[0], '%d/%m/%Y')
  37.     tempDates.append('"' + tempDate.strftime('%m/%d/%Y') + '"' + ',' + '\n')
  38.     tempValue = int(float(tempLine.split()[6])*1000)
  39.     tempValues.append(str(tempValue) + ',' + '\n')
  40.  
  41. tempDates[-1] = tempDates[-1].replace(',', '')
  42. tempValues[-1] = tempValues[-1].replace(',', '')
  43.  
  44. fDates.writelines(tempDates)
  45. fValues.writelines(tempValues)
  46.  
  47. fDates.close()
  48. fValues.close()
  49. fAdjustLog.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement