[sword-svn] r116 - trunk/flashtools

scribe at www.crosswire.org scribe at www.crosswire.org
Sat Nov 3 18:00:32 MST 2007


Author: scribe
Date: 2007-11-03 18:00:31 -0700 (Sat, 03 Nov 2007)
New Revision: 116

Added:
   trunk/flashtools/csvconv.cpp
Log:
added simple csv conversion tool


Added: trunk/flashtools/csvconv.cpp
===================================================================
--- trunk/flashtools/csvconv.cpp	                        (rev 0)
+++ trunk/flashtools/csvconv.cpp	2007-11-04 01:00:31 UTC (rev 116)
@@ -0,0 +1,46 @@
+#include <swbuf.h>
+#include <filemgr.h>
+#include <iostream>
+
+using namespace sword;
+using namespace std;
+
+
+
+
+void processLine(SWBuf line) {
+	line += "|";
+	const char *field = line.stripPrefix('|');
+	cout << "[" << field << "]\n";
+	const char *keys[] = { "Language", "TWOT", "Form", "GkRelated", "FullerMeaning", "UnpointedHeb", "CALUnpointedAscii", "TABSUnpointedAscii", "PointedHeb", "Transliteration", "Phonetic", "Notes", "Meaning", "FullMeaning", "TranslationInAV", 0 };
+	for (int i = 0; keys[i]; i++) {
+		field = line.stripPrefix('|');
+		if (!field) break;
+		cout << keys[i] << "=" << field << "\n";
+	}
+}
+
+
+
+
+int main(int argc, char **argv) {
+
+	FileMgr fmgr;
+	SWBuf line;
+
+	char *fname = "hebrewDiB.csv";
+
+	if (argc > 1) fname = argv[1];
+
+	FileDesc *in = fmgr.open(fname, O_RDONLY);
+
+	while (fmgr.getLine(in, line)) {
+		line.trim();
+		if (line.length()) {
+			processLine(line);
+		}
+	}
+
+	fmgr.close(in);
+	return 0;
+}




More information about the sword-cvs mailing list