diff options
Diffstat (limited to 'flashtools/csvconv.cpp')
-rw-r--r-- | flashtools/csvconv.cpp | 46 |
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; +} |