Created
June 20, 2020 07:42
-
-
Save robosina/ce10d7d728cd93d5a5eee78a3f3fce90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QCoreApplication> | |
#include <QFile> | |
#include <QTextStream> | |
#include <QDebug> | |
void convert_date(QString& date) | |
{ | |
date=date.mid(0,4)+"-"+date.mid(4,2)+"-"+date.mid(6,2); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
QFile file("/home/isv/Downloads/Takceram.csv"); | |
file.open(QIODevice::ReadOnly); | |
QTextStream in(&file); | |
QFile fileout("/home/isv/Downloads/Takceram2.csv"); | |
fileout.open(QIODevice::WriteOnly); | |
QTextStream out(&fileout); | |
std::vector<QString> vec; | |
while(!in.atEnd()) | |
{ | |
QString line=in.readLine(); | |
vec.push_back(line); | |
} | |
vec.erase(vec.begin()); | |
std::reverse(vec.begin(),vec.end()); | |
out<<"Date,Open,High,Low,Close,Adj Close,Volume"<<endl; | |
for (int var = vec.size()-400; var < vec.size(); ++var) | |
{ | |
// qDebug()<<line; | |
QStringList lis=vec[var].split(","); | |
QString date=lis[1]; | |
convert_date(date); | |
QString open=lis[2]; | |
QString high=lis[3]; | |
QString low=lis[4]; | |
QString close=lis[5]; | |
QString last=lis[11]; | |
QString vol=lis[7]; | |
out<<date<<","<<open<<","<<high<<","<<low<<","<<close<<","<<last<<","<<vol<<endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment