Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io
- import datetime
- #from: fAdjustLog.txt
- """
- 06/11/2019 IND - Ibovespa Z19 109.091 108.876 -215 215,00
- 05/11/2019 IND - Ibovespa Z19 109.228 109.091 -137 137,00
- [...]
- """
- #to: adjLogValuesStrip.txt
- """
- 108876,
- 109091,
- [...]
- """
- #and to: adjLogDatesStrip.txt
- """
- "11/06/2019",
- "11/05/2019",
- [...]
- """
- fDates = io.open("adjLogDatesStrip.txt","wt")
- fValues = io.open("adjLogValuesStrip.txt", "wt")
- fAdjustLog = io.open("fAdjustLog.txt","rt")
- tempLines = fAdjustLog.readlines()
- tempDates = []
- tempValues = []
- for tempLine in tempLines:
- tempDate = datetime.datetime.strptime(tempLine.split()[0], '%d/%m/%Y')
- tempDates.append('"' + tempDate.strftime('%m/%d/%Y') + '"' + ',' + '\n')
- tempValue = int(float(tempLine.split()[6])*1000)
- tempValues.append(str(tempValue) + ',' + '\n')
- tempDates[-1] = tempDates[-1].replace(',', '')
- tempValues[-1] = tempValues[-1].replace(',', '')
- fDates.writelines(tempDates)
- fValues.writelines(tempValues)
- fDates.close()
- fValues.close()
- fAdjustLog.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement