summaryrefslogtreecommitdiffstats
path: root/flashtools/csvconv.cpp
diff options
context:
space:
mode:
authorTroy A. Griffitts <scribe@crosswire.org>2007-11-04 01:00:31 +0000
committerTroy A. Griffitts <scribe@crosswire.org>2007-11-04 01:00:31 +0000
commit33c73a70dce8df9e88e3539217004d4c2c90927b (patch)
treeec991f044e3dc87c243ee66914f88a685f478650 /flashtools/csvconv.cpp
parentb485b78f1ada861fdade27b5fdaeb7a7cea6d026 (diff)
downloadsword-tools-33c73a70dce8df9e88e3539217004d4c2c90927b.tar.gz
added simple csv conversion tool
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@116 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'flashtools/csvconv.cpp')
-rw-r--r--flashtools/csvconv.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/flashtools/csvconv.cpp b/flashtools/csvconv.cpp
new file mode 100644
index 0000000..c6d67bd
--- /dev/null
+++ b/flashtools/csvconv.cpp
@@ -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;
+}