CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
authorSebastian Brannstrom <sebastianb@symbian.org>
Mon, 09 Aug 2010 17:16:20 +0100
changeset 21 3bfc3227045d
parent 20 a7451a8eb5dc
child 22 d5911f90500d
CSV reader works, kind of. contacts.csv file added to project, must live in c:\ at the moment
contactengine/contacts.csv
contactengine/dbtools.cpp
contactengine/main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/contacts.csv	Mon Aug 09 17:16:20 2010 +0100
@@ -0,0 +1,131 @@
+Name,Mobile,Deskphone,Xtn,email,Skype,Twitter,Title,Site,Department,Floor
+Adams  Mar,86-1391-0000-440,,,adamsm@symbian.org,leilei.wang,,Global Alliance China,Beijing,GAT
+Alex Abramovich,+44 7947 035516,,1101,alexa@symbian.org,al211120,alexabramovich,Developer Website Editor,London,Marketing,Lower ground
+Ambrish,+44 7590 245222,,-,ambrishp@symbian.org,ambrishp.symbian,-,IS Support/BSG,London,IT,Lower ground
+Amit Shah,+44 7816315857,,1108,amits@symbian.org,amits.symbian,,IS Support/BSG,London,IT,Lower ground
+Andrew Longworth,+44 7554 401999,,1105,andrewl@symbian.org,andrewl.symbian,andyklongworth,Content Editor,London,Marketing,Ground
+Andrew Simpson,+44 7917 750342,,1107,andrews@symbian.org,andrews.symbian,andy2simpson,Integration Lead,London,TDM,Ground
+Andy Powers,+44 7747 065815,,1106,andyp@symbian.org,andyp.symbian,andypowers,Software Accrediation,London,Programs,2nd
+Angela Coppola,1-510-495-4455,,,angelac@symbian.org,coppola.angela,calisymbianite,Office Manager,Foster City,GAT,5th
+Anna Alfut,+44 7771376826,,,annaa@symbian.org,,,Brand and Design,London,Marketing,Ground
+Annabel Cooke,+44 7769 588932,,1104,annabelc@symbian.org,annabelc.symbian,annabelcooke,Brand & Design,London,Marketing,Lower ground
+Arnaud Lenoir,+44 7771 376859,,1102,arnaudl@symbian.org,arnaudl.symbian,arnaudlsymbian,Multimedia Tech Specialist,London,TDM,Ground
+Arunabh Ankur,+44 7771376840,,,,arunabha.symbian,,,London,,Ground
+Ashlee Goodwin,+44 7771 376807,,1109,ashleeg@symbian.org,ashleeg.symbian,ashleegodwin,PR and Comms,London,Marketing,2nd
+Brendan Donegan,+44 7771 376827,,,brendand@symbian.org,,brendan_donegan,Test Engineer,London,TDM,Ground
+Carlton Assie,+44 7771 376805,,1111,carltona@symbian.org,carltona.symbian,,Security and Facilities ,London,Facilities,-
+Chetan Kapoor,+44 7876-254947,,1182,chetank@symbian.org,chetan_kapoor,,Integration & Build Engineer ,London,TDM,Ground
+Chris Davidson,+44 7771 376836,,1112,chrisd@symbian.org,chrisdavosymbian,davodavo225,Strategic Programmes Manager,London,TDM,1st
+Craig Box,+44 7771 376 833,,1199,craigb@symbian.org,craigb.symbian,craigbox,IT Architect,London,IT,Lower ground
+Craig Heath,+44 7765 222659,,1113,craigh@symbian.org,craigh.symbian,heathcr,Chief Security Technologist,London,TDM,1st 
+Daisy Dunkley-Clark,+44 7825 256130,,1118,daisyd@symbian.org,daisyd.symbian,DaisyDC,Head of Global PR & Comms,London,Marketing,2nd
+Daniel Rubio,+44 7738 808995,,1115,danielr@symbian.org,danielr.symbian,,"Team Lead, Chief Architect, OS and Base Technology",London,TDM,1st
+Dario Sestito,+44 7823 533820,,1116,darios@symbian.org,darios.symbian,,Integration and Build Engineer,London,TDM,Ground
+David Chun,,,,davidc@symbian.org,david_chun,,"Head of China, Global Alliances",Beijing,GAT
+ahra,+1-415 205 1555,"UK +44 7920 582 759
+",,dennisl@symbian.org,leejai25,leejai25,Product Marketing,Foster City,Marketing,5th
+Dianne Crowther,+44 78 2525 5949,,1155,diannec@symbian.org,diannec.symbian,DianneCrowther,Legal Counsel,London,Legal,1st
+Dietmar Tallroth,358 504 836 635,+44 7771 376837,1119,dietmart@symbian.org,dietmart.symbian,,Leadership Team - Legal,Helsinki,Legal,-
+Dining Room,,,1252
+"Effimia Vraka
+","+44 7771 376863
+",,,effimiav@symbian.org,effimiav.symbian,,Multimedia Apps Technology Specialist  ,London,TDM,1st
+Eoin Russel,+44 7771 376830,,1121,eoinr@symbian.org,,,,Home
+Elisabeth Gettelman,1-415-238-1915,,7604,elisabethg@symbian.org,elisabethg.symbian,elisabethgettelman,PR & Comms Manager - US,Foster City,Marketing
+Elisabeth Lutgendorff,+44 7771 376846,,,elisabethl@symbian.org,,,Programs Coordinator,London,Programs,2nd
+Eugene Ostroukhov,1-650-504-1325,,,eugeneo@symbian.org,,,Team Tools,Foster City,TDM,5th 
+Fred Blesser,+44 7771 376811,,,fredb@symbian.org,fredb.symbian,,Technology Manager Collaborative Test,London,TDM,Ground
+Gareth Long,"+44 7771 376858
+",,,garethl@symbian.org,garethl.symbian,,Teachnical Lead,London ,TDM,Ground
+"Gaurav Katyal 
+",+44 7771 376862,,,gauravk@symbian.org,gauravk.symbian,GauravKatyal,"Connectivity Technology Specialist 
+",London,TDM,1st
+Gavin O'Day,+44 7771 376802,+44 20-7783-6518,1124,gavino@symbian.org,gavino.symbian,gavin511,Facilities Manager,London,Facilities,1st
+Gemma Reyes,650-557-6182,650-645-7500,7566,gemmar@symbian.org,gemma_reyes,,Office and Executive Administrator,Foster City,GAT,5th
+Hamish Willee,61 4300 44108,,,hamishw@symbian.org,hamishgw,,Technical Editor Online Content,Home (Australia),Marketing
+Hendrik Fink,,,,hendrikf@symbian.org,hendrikfink,,,Foster City,Product Marketing
+Hyojung Yun,82 10 3898 8408,,,hyojungy@symbian.org,hyojung_yun,,Global Alliances/Korea,Seoul,GAT
+Ian Hutton,+44 7747 065763,,1127,ianh@symbian.org,ianh.symbian,mylifeinpixels,Roadmap Manager,London,TDM,1st
+Ian McDonald,+44 7771 376 847,+44 20 7401 1166,1179,ianm@symbian.org,imcdnzl,imcdnzl,Head of IT,London,IT,Lower ground
+Ivan Litovski,+44 7771 376813,,1128,ivanl@symbian.org,ivanl.symbian,,Technical Editor Online Content,London,Marketing,Ground
+James Aley,+44 777-137-6841,,1181,jamesa@symbian.org,jamesa.symbian,jamesaley,Apps & UI Technology Specialist ,London,TDM,1st
+James Melbow,+44 7771 376 815,-,1120,jamesm@symbian.org,jamesm.symbian,jamesmsymbian,Technical Services Coordinator,London,IT,Lower ground
+Jennifer Vancini,1 650-575-7430,,7562,jenniferv@symbian.org,jvancini,,Acting GM/USA,Foster City,GAT,5th
+Jessie Hu,+44 7771 376812,,1129,jessieh@symbian.org,universe_hu,,Product Management,London,Marketing,Lower ground
+Jim Clarke,+44 7747 065502,,1130,jimc@symbian.org,jimc.symbian,_jimc,Delivery Management,London,TDM,Ground
+Johanna Arola,+44 7766-990-111,,,johannaa@symbian.org,,,Tech Operations Manager,London,TDM,2nd
+John Forsyth,+44 7747 065706,020 7401 1152,1152,johnf@symbian.org,johnf.symbian,,Leadership Team - Technology and Delivery Management,London,TDM,1st
+John Forsyth Conference Phone,,,1251
+John Kern,1-650-346-6766,,7568,johnk@symbian.org,john.kern704,kern3020,Developer Support Specialist,Foster City,Programs
+Jose Smit,+44 7765 222708,+44 20-7401-1158,1133,joses@symbian.org,joses.symbian,josesmit,Team Administrator ,London,TDM,Ground
+Junko Tsuyuki,81 (0)80 1288 2675,81 (0)3 3500 5231,19,tsuyukij@symbian.org,junko.tsuyuki,,Team Administrator,Tokyo,GAT
+Kazuhiro Konishi,81 (0)80 1142 2673,81 (0)3 45009192,12,konishik@symbian.org,konishikaz,konishikaz,Community Manager,Tokyo,GAT
+Krishna Achugatla,1-650-438-2268,,,krishnaa@symbian.org,,,Tools Integration Specialist,Foster City,TDM,5th
+Kyoko Horikawa,81 (0)80 1273 3167,81 (0)3 4500 9195,15,horikawak@symbian.org,,,Communications Manager,Tokyo
+Larry Berkin,1-650-892-1822,,7544,larryb@symbian.org,larryberkin,,Leadership Team - Global Allences and Country Operations,Foster City,GAT,5th
+Lars Kurth,+44 7788 576 889,,1134,larsk@symbian.org,lars.kurth,,Contributor/Package Owner,London,TDM,Lower ground
+Laura Chuck,+44 7824 847915,+44 20-7783-6519,1135,laurac@symbian.org,laurac.symbian,Laura_Chuck,HR Busniness Partner,London,HR,1st
+Laura Nixon,+44 7768 421003,,1136,lauran@symbian.org,,,Global Alliance,London,GAT,2nd
+Lauren Lamonica,1-415-902-3191,,7565,laurenl@symbian.org,lauren.lamonica,,Product Management,Foster City,Marketing,5th
+Lauren Sarno,+44 7748-480-580,home office land line: +44 1223 351 930,1180,laurens@symbian.org,laurens.symbian,Lauren_Sarno,Head of Membership,London ,Programs,Lower ground
+Lee Williams,+44 7825 500878 / 0777 137 6800	,+44 20-7783-6501,1151,leew@symbian.org,leemwilliams,leemwilliams,Leadership Team - Executive Director,London,Acquistion,2nd
+Lee Williams Conference Phone,,,3521
+Library Conference Phone,,,1253
+Loan Conference Phone,,,1159
+"Maciej Seroka
+",+44 7771 376 839,,,maciejs@symbian.org,maciejs.symbian,,Test Engineer,London,TDM,Ground
+Magda Voigt,+44 7771 376803,,1139,magdav@symbian.org,magdav.symbian,,Online Content Manager,London,Marketing,Lower ground
+Mark Skrebels,+44 7747 065760,,1201,marks@symbian.org,marks.symbian,skrebs1,Senior Release Manager (RC),London,TDM,Ground
+Mark Wilcox,+44 7813 404978,,1140,markw@symbian.org,markw.symbian,symbian_markw,Kernel and HW Technology Manager,London,TDM
+Martin Webb,+44 7771 376842,0,,martinw@symbian.org,martinw.symbian,,"Multimedia Technology Manager
+",London,TDM,1st
+Michiko Nagai, +81(0)90 3067 9816, +81(0)3 4500 9193,1113,michikon@symbian.org,michiko.nagai0224,michikonagai,Web Manager,Tokyo
+Mike Heald,+44 7771 376 843,,,mikeh@symbian.org,quitehypnotic,thejedimaster,Systems Administrator,London,IT,Lower ground
+Mike Kinghan,+44 7765 222793,,1143,mikek@symbian.org,mike.kinghan,,Test Lead,London,TDM,Ground
+Miriam Mickail,+44 7771 376809,+44 20-7783-6526,1154,miriamm@symbian.org,miriamm.symbian,MiriamMickail,Team Administrator,London,TDM,1st
+"Nithya Rajendrababu
+",+44 7771 376860,,1110,nithyar@symbian.org,nithyarb.symbian,nithya_sf,Release Manager,London,DM,Ground
+Oliver Gunasekara,+1 408 660 3189,NA,7577,OliverG@Symbian.org,Oly2004,OlyG,Head of North America,Foster City,GAT,5th
+Pat Downey,+44 7771376820,,,patd@symbian.org,patd.symbian,pat_downey,Configeration Management Engineer,London,TDM,Ground
+Paul Beusterien,1-650-918-7074,,7571,paulb@symbian.org,paul.beusterien,paulbeusterien,Team Lead Tools,Foster City,TDM,5th
+Peter Williamson,+44 7771 376819,,1145,peterw@symbian.org,peterw.symbian,PeteRabNZ,Finance and Administration,London,Finance,1st
+Pui Hang Miles (Pn),+44 7771 376 799,,1153,pn@symbian.org,puihang,Talk2PN,Executive Assistant,London,Leadership Team,2nd
+Raya Breit,1-650-740-8533,,7570,rayab@symbian.org,raya.breit,,Developer Programs,Foster City,,5th
+Reception/Security,+44 7771 376806,,1150
+Reena Varsani,+44 7771376864,,,Reenav@symbian.org,reenav.symbian,,Accounts Assistant,London,Finance
+Richard Baruch,+44 7747 065817,,1147,richardb@symbian.org,richardb.symbian,  r_baruch,Metrics Engineer,London,TDM,Ground
+Richard Collins,+44 7771 376835,,1148,richardc@symbian.org,richardc.symbian,,Connectivity Technology Manager ,London,TDM,1st
+Ricky Gahru,"+44 7771 376845
+",,1183,rickyg@symbian.org,rickyg.symbian,,Accounts Assistant,London,Finance,1st
+Robert Ackland,+44 7771 376829,,1146,robertac@symbian.org,robertac.symbian,,"Team Lead, Apps and Services ",London,TDM,1st
+Roderick Burns,+44 7823 533822,,1173,roderickb@symbian.org,burnsrod,rodburns,Developer Services,London,Programs,Ground
+Roelof Kotze,+44 7771 376834,,1172,roelofk@symbian.org,roelofk.symbian,roelof_kotze,Member and Community support,London,,Lower ground
+Ryo Inowa, +81 (0)90 7723 0989, +81 (0)3 4500 9194,14,inowar@symbian.org,,,Community Manager,Tokyo,GAT
+Salvatore Rinaldo,+44 7771 376831,,1174,salvatorer@symbian.org,salvatorer.symbian,,Apps & UI Technology Specialist ,London,TDM,1st
+Satu Dahl,+44 7919 310909,,1175,satum@symbian.org,,,Horizon Editor,London,Programs,2nd
+Scott Weiss,+44 7771 376818,,1176,scottweiss@symbian.org,scottw.symbian,,Apps & Services Technology Manager (UI),London,TDM,1st
+Sebastian Brannstrom,"+44 782-525-6101
+",,,sbrannstrom@symbian.org,leskip,teknolog,Release Manager,London,DM,Ground
+Security Reception/Cellar,,,3524
+Sergei Krot,+44 7771 376 866,,,sergeik@symbian.org,kolbiks,kolbix,Web developer,London,Marketing,Lower ground
+Shabe Razvi,+44 7747 065644,,1157,shaber@symbian.org,shaber.symbian,shabe,Integration & Build  Engineer,London,TDM,Ground
+Shaun Phillips,+44 7747 065 885,,1177,shaunp@symbian.org,dragonchat_uk,shaunph,Service Delivery Manager,London,IT,Lower ground
+Shuo Yang,0086 13911620373,,,shuoy@symbian.org,heavan_rain,,Global Alliance China,Beijing  ,GAT
+Simon Howkins,+44 7763 102896,,1158,simonh@symbian.org,Simon.Howkins,,Integration & Build Engineer,London,TDM,Ground
+Simon Pope,0776-522-2308,,,simonp@symbian.org,,,Developer Support Specialist,London,UKCU,2nd
+Siobhan Keane,+44 7771 376817,,1150,siobhank@symbian.org,siobhank.symbian,siobhank,Facilities,London,,1st
+Steve Warner,+44 7771 376804,+44 20-7783-6504,1160,stevew@symbian.org,stevew.symbian,,Leadership Team - HR,London,HR,1st
+Susana Posada,+44 7771 376 814,,,susanap@symbian.org,susanap.symbian,aradiaajiin,Community Coordinator,London,Programs,2nd
+Sylvester Oseghale,+44 7785297650,,1162,sylvestero@symbian.org,sylvestero.symbian,bigbure,IS Support/BSG,London,IT,1st
+Tahir Mahmood,+44 7825 255993,,1163,tahirm@symbian.org,tahirm.symbian,tahirmahmood,Configuration Manager,London,TDM,Ground
+Terho Niemi,358 500 820 409,,,terhon@symbian.org,terhon.symbian,,"Technology Manager, Browser, Web and Run Time Productivity",Helsinki,TDM
+Thomas Pritchard,+44 7747 065742,,1167,tomp@symbian.org,tomp.symbian,tajpritchard,Team Lead - Connectivity ,London,TDM,1st
+Tim Holbrow,+44 7747 065 557,NA,1168,timh@symbian.org,timh.symbian,timholbrow,Leadership Team - Operations Support,London,Programs,1st
+Tim Williams,+44 7747 065 684,,,timw@symbian.org,timw111666,,Technical Editor,London,Marketing
+Todd Benzies,1.650.576.4443 ,arn,,toddb@symbian.org,toddb.symbian ,,Events Manager,Foster City,Programs
+Urmi Shah,+44 7747 065429,,,urmis@symbian.org,urmis.symbian,urmitalk,Release Manager ,London,TDM,Ground
+Victor Palau,+44 7823 533829,,1169,victorp@symbian.org,victorp.symbain,victorpalau,Senior Release Manager,London,TDM,Ground
+William Roberts,+44 785 550 0495,,1170,williamr@symbian.org,williamr.symbian,,Chief Integration Engineer,London,TDM,Ground
+Yasin Hamed,"""+358 407 604892",,,YasinH@Symbian.org,yasin.hamed,,Nokia Global Alliances,Helsinki,GAT
+Yoshimasa Miyake,"""+ 81 80 1203 8952",81(0)3 4500 9191,11,yoshim@symbian.org,miyake_888,,Head of Japan,Tokyo,GAT
+Zahra Somji,+44 7771 376 828,+44 20-7401-1163,1171,zahras@symbian.org,zahras.symbian,zahra83,HR Administrator,London,HR,1st
\ No newline at end of file
--- a/contactengine/dbtools.cpp	Mon Aug 09 14:37:31 2010 +0100
+++ b/contactengine/dbtools.cpp	Mon Aug 09 17:16:20 2010 +0100
@@ -1,11 +1,14 @@
 #include <QtCore/QCoreApplication>
 #include <QtSql>
+#include <QFile>
 
 #include "database.h"
 #include "dbtools.h"
 
 bool DBTools::createTable(QString sqlStmt)
 {
+    qDebug() << "DB: create table statement: " << sqlStmt << endl;
+
     QSqlQuery query;
     return query.exec(sqlStmt);
 }
@@ -65,7 +68,7 @@
     // Find QSLite driver
     db = QSqlDatabase::addDatabase("QSQLITE");
 
-    db.setDatabaseName("C:\\workspace\\QtExamples\\contactengine\\contactengine.db");
+    db.setDatabaseName("C:\\contactengine.db");
 
     // Open databasee
     if(!db.open())
@@ -88,8 +91,9 @@
                 "title varchar(128),"
                 "site int,"
                 "department int,"
-                "floor int");
+                "floor int)");
 
+    qDebug() << "DB: create table rc=" << rc << endl;
     return rc;
 }
 
@@ -102,12 +106,77 @@
 
 void DBTools::importCSV(QString fileName)
 {
+    QFile file(fileName);
+    QString line;
 
+    if (file.open(QFile::ReadOnly)) {
+        qDebug() << "importCSV file open OK" << endl;
+        char buf[1024];
+
+        while(!file.atEnd())
+        {
+            file.readLine(buf, sizeof(buf));
+            QString string(buf);
+            //qDebug() << string;
+            QStringList stringList = string.split(",");
+
+            //qDebug() << "count: " << stringList.count() << endl;
+            QStringListIterator iter(stringList);
+
+            QString strName;
+            QString strMobile;
+            QString strDeskphone;
+            QString strXtn;
+            QString strEmail;
+            QString strFloor;
+            QString strSkype;
+            QString strTwitter;
+            QString strTitle;
+            QString strSite;
+            QString strDepartment;
+
+            if (stringList.count() > 0)
+                strName = stringList[0];
+
+            if (stringList.count() > 1)
+                strMobile = stringList[1];
+
+            if (stringList.count() > 2)
+                strDeskphone = stringList[2];
+
+            if (stringList.count() > 3)
+                strXtn = stringList[3];
+
+            if (stringList.count() > 4)
+                strEmail = stringList[4];
+
+            if (stringList.count() > 5)
+                strSkype = stringList[5];
+
+            if (stringList.count() > 6)
+                strTwitter = stringList[6];
+
+            if (stringList.count() > 7)
+                strTitle = stringList[7];
+
+            if (stringList.count() > 8)
+                strSite = stringList[8];
+
+            if (stringList.count() > 9)
+                strDepartment = stringList[9];
+
+            if (stringList.count() > 10)
+                strFloor =stringList[10];
+
+            qDebug() << strName << strTitle << endl;
+      }
+    }
 }
 
 DBTools::DBTools(QObject *parent)
 {
     QObject();
+    createDB();
 }
 
 DBTools::~DBTools()
--- a/contactengine/main.cpp	Mon Aug 09 14:37:31 2010 +0100
+++ b/contactengine/main.cpp	Mon Aug 09 17:16:20 2010 +0100
@@ -1,11 +1,15 @@
 #include <QtGui/QApplication>
 #include "mainwindow.h"
+#include "dbtools.h"
 
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
     MainWindow w;
 
+    DBTools dbt;
+    dbt.importCSV("c:\\contacts.csv");
+
 #if defined(Q_WS_S60)
     w.showMaximized();
 #else