summaryrefslogblamecommitdiffstats
path: root/flashtools/csvconv.cpp
blob: 9ff33e25b285cc29baf8c1018b47f022529541bc (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                  
                                                                                                                                                                                                                                                           


                                              





                                                       










                                 
                                        














                                                  
#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[] = { "PointedHeb", "Language", "Meaning", "TWOT", "Form", "GkRelated", "FullerMeaning", "UnpointedHeb", "CALUnpointedAscii", "TABSUnpointedAscii", "Transliteration", "Phonetic", "Notes", "FullMeaning", "TranslationInAV", 0 };
	for (int i = 0; keys[i]; i++) {
		field = line.stripPrefix('|');
		if (!field) break;
          if (!strcmp("PointedHeb", keys[i])) {
               cout << "UTF8=" << field << "\n";
          }
          else {
               cout << keys[i] << "=" << field << "\n";
          }
	}
}




int main(int argc, char **argv) {

	FileMgr fmgr;
	SWBuf line;

	char *fname = "STRONGSLIST.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;
}