summaryrefslogtreecommitdiffstats
path: root/flashtools/csvconv.cpp
blob: 9ff33e25b285cc29baf8c1018b47f022529541bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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;
}