[Moved] CSV File to XML File
-
wrote on 12 Jul 2011, 09:32 last edited by
Hi All
Is there any way by which i can convert CSV file to XML file.
or Can i export contents of QTableWidget to XML File
-
wrote on 12 Jul 2011, 09:42 last edited by
Nope, you should write your own custom converter.
-
wrote on 12 Jul 2011, 11:54 last edited by
Don't fear. Writing XML with Qt is very simple.
The documentation of QDomDocument contains template code for you. -
wrote on 12 Jul 2011, 12:13 last edited by
To read content of a CSV-File you could split the content by using QRegExp. Use ; as splitter.
-
wrote on 12 Jul 2011, 14:39 last edited by
[quote author="jensen82" date="1310472822"]To read content of a CSV-File you could split the content by using QRegExp. Use ; as splitter.[/quote]
No, don' t do that. What happens if the contents between " happens to contain a semicolon? Then you are in big trouble. Use a decent CSV parser instead, it is not as trivial as just splitting lines on a separator. -
wrote on 12 Jul 2011, 15:29 last edited by
There is no need to write a CSV parser. There are millions available.
A Qt CSV parser:
http://sourceforge.net/projects/qcsv/ -
wrote on 12 Jul 2011, 20:16 last edited by
I'm using boost::spirit for text-parsing. Very fast!
-
wrote on 12 Jul 2011, 20:34 last edited by
Hm, Spirit is overhead for csv parsing I think.
-
wrote on 12 Jul 2011, 22:07 last edited by
I moved this thread to the brainstorm forum, as it's only marginally Qt related.
1/9