Sub MySub2()
Application.DisplayAlerts = False
filenamebase = "C:\Users\w8jcd_000\Documents\Nayuta\USRDIR\script\"
For Each Sheet In ActiveWorkbook.Worksheets
Sheet.Activate
myfilename = filenamebase + Sheet.Name + ".txt"
ActiveWorkbook.SaveAs Filename:=myfilename, _
FileFormat:=xlUnicodeText, CreateBackup:=False
Next
Application.DisplayAlerts = True
End Sub
import os
def get_data(filename):
totalbytes = os.path.getsize(filename)
infile = open(filename, 'rb')
totalfiledata = infile.read(totalbytes)
infile.close()
return totalfiledata
mypath = os.path.dirname(os.path.realpath(__file__)) #path of this python file
files = [ f for f in os.listdir(mypath) if \
os.path.isfile(os.path.join(mypath,f)) ]
for myfile in files:
if os.path.splitext(myfile)[1] == '.txt':
filedata = get_data(myfile)
filedata = filedata[2:].decode('utf_16_le') #first 2 bytes are an Excel flag
outfile = open(os.path.splitext(myfile)[0],'wb')
outfile.write(filedata.encode('cp932'))
outfile.close()
Sub WriteTSV()
Const strPathBaseName As String = "C:\Users\w8jcd_000\Documents\Nayuta\USRDIR\script\"
Dim filename As String
Const adTypeText = 2
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Dim myObj As Variant
For Each myObj In ActiveWorkbook.Worksheets
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Charset = "shift-jis"
BinaryStream.Type = adTypeText
myObj.Activate
Set wkb = ActiveWorkbook.ActiveSheet
If wkb.Name = "Noi_orig" Then
filename = strPathBaseName + "noi.data"
Else
filename = strPathBaseName + "mp_" + wkb.Name + ".data"
End If
BinaryStream.Open
For r = 1 To wkb.UsedRange.Rows.Count
s = ""
For c = 1 To wkb.UsedRange.Columns.Count
s = s & wkb.Cells(r, c).Value & Chr(9)
Next c
BinaryStream.WriteText s, 1
Next r
BinaryStream.SaveToFile filename, adSaveCreateOverWrite
BinaryStream.Close
Set BinaryStream = Nothing
Next
End Sub
Patch 3
Still a ways to go I think.
Museum sub-areas are not translated. Every other string in the whole script has a translation.
I'll look into:
Faster text display speed.
Translation for quests, stage names, goal descriptions, character names.
...
I hope you will enjoy this patch.
What ? Oo15,579 opcodes with text in them
29,862 lines with text in them
function ConvertToTSV(sheet) {
var ws = sheet.getDataRange();
try {
var data = ws.getValues();
// Loop through the data in the range and build a string with the TSV data
var csv = "";
for (var row = 0; row < data.length; row++) {
// Join each row's columns
// Add a carriage return to end of each row
csv += data[row].join("\t") + "\r\n";
}
return csv;
}
catch(err) {
Logger.log(err);
Browser.msgBox(err);
}
}
function BulkTSVExport() {
var myFolder = DriveApp.createFolder(SpreadsheetApp.getActiveSpreadsheet().getName());
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i = 0; i < sheets.length; i++) {
var csv = ConvertToTSV(sheets[i]);
myFolder.createFile(sheets[i].getName() + ".tsv", csv);
}
}
function TSVExport() {
var sheet = SpreadsheetApp.getActiveSheet();
var csv = ConvertToTSV(sheet);
DriveApp.createFile(sheet.getName() + ".tsv", csv);
}
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [
{name : "Export Current Sheet to TSV", functionName : "TSVExport"},
{name : "Export All Sheets to TSV", functionName : "BulkTSVExport"}
];
spreadsheet.addMenu("TSV", entries);
}