How do I sort Data in a CSV by groups using QT?
I have CSV file of servers separate by \r\n with unwanted word *serverlist" at the beginning of the file and unwanted "*" at the end.
Code:
*serverlist\r\n#HostName,IP,Score,Ping,Speed,CountryLong,CountryShort\r\nserver2x.selfip.xx,111.100.240.10,605268,8,380099315,Japan,JP\r\nserve2x.selfip.xx,39.110.61.222,602280,3,625856265,Japan,JP\r\nserver2x.selfip.xx,46.5.0.129,400121,15,15754028,Germany,DE\r\n*\r\n
Am downloading this from a remote server using QNetworkAccessManager and QNetworkReply
Code:
for(QString data
: csvdata.
replace("\r",
"").
split("\n")){ srvlist =data.split(',');
//Having Got a First List in the Firts Iteration,How Can I get each item in the list? so as I can send it to my Database table using below Sql query
// INSERT INTO serverlisttable (id, hostname, IP,score...) VALUES (1, 'listitem at [0]', 'list item at [1]'...)
}
My Goal is to Store this type of Data by Group into a Database in this Format for easy searching
Code:
ID HostName IP Score Ping Speed CountryLong CountryShort
1 server2x.selfip.xx 111.100.240.10 605268 8 380099315 Japan JP
2 serve2x.selfip.xx 39.110.61.222 602280 3 625856265 Japan JP
Your help will be appreciated
Re: How do I sort Data in a CSV by groups using QT?
So what's the problem? You basically wrote the code in your // INSERT comment. 'listitem at [0]' is simply svrlist[0] or svrlist.at(0). Read the documentation for QList. As always in Qt, if you don't see the method you need in the class you are looking at, check its base classes.