-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
80 lines (73 loc) · 2.83 KB
/
Program.cs
File metadata and controls
80 lines (73 loc) · 2.83 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
namespace LoTable_LocalizationExtracter
{
class Program
{
public class Row
{
public Row(string Id) {
this.Id = Id;
}
public string Id { get; set; }
public string KO { get; set; }
public string JP { get; set; }
public string EN { get; set; }
public string TC { get; set; }
}
static int Main(string[] args)
{
string[] files =
{
"Table_Localization_ko.bin.bytes",
"Table_Localization_ja.bin.bytes",
"Table_Localization_en.bin.bytes",
"Table_Localization_tc.bin.bytes",
};
System.Collections.Generic.Dictionary<string, Row> final_d = new System.Collections.Generic.Dictionary<string, Row>();
for (int i = 0; i < files.Length; i++)
{
string filepath = files[i];
if (!File.Exists(filepath))
{
Console.WriteLine($"File {filepath} not found.");
continue;
}
StreamReader streamReader = new StreamReader(filepath);
BinaryFormatter binaryFormatter = new BinaryFormatter();
System.Collections.Generic.Dictionary<string, System.Object> d = (System.Collections.Generic.Dictionary<string, System.Object>)binaryFormatter.Deserialize(streamReader.BaseStream);
foreach (var kvp in d) {
if (!final_d.ContainsKey(kvp.Key)) {
final_d.Add(kvp.Key, new Row(kvp.Key));
}
switch (i) {
case 0:
final_d[kvp.Key].KO = (string)kvp.Value;
break;
case 1:
final_d[kvp.Key].JP = (string)kvp.Value;
break;
case 2:
final_d[kvp.Key].EN = (string)kvp.Value;
break;
case 3:
final_d[kvp.Key].TC = (string)kvp.Value;
break;
}
}
}
string savecsv = "final.csv";
using (var writer = new StreamWriter(savecsv))
using (CsvHelper.CsvWriter csv = new CsvHelper.CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.WriteHeader<Row>();
csv.NextRecord();
csv.WriteRecords(final_d.Select(kvp => kvp.Value).ToList());
}
return 0;
}
}
}