【升级】升级 NeoLua 版本
【修复】修复 table input属性包含多余逗号,导致empty字符串''也被识别为目录,错误将整个input_data_dir目录当作数据源的bug 【优化】引用UDE库,智能识别csv文件编码,非utf8格式csv也能被正常识别main
parent
861015e802
commit
5c35c140b3
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
||||
<PackageReference Include="NeoLua" Version="1.3.11" />
|
||||
<PackageReference Include="NeoLua" Version="1.3.13" />
|
||||
<PackageReference Include="Ude.NetStandard" Version="1.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -18,13 +18,29 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
|||
private readonly List<Sheet> _sheets = new List<Sheet>();
|
||||
|
||||
|
||||
private System.Text.Encoding DetectCsvEncoding(Stream fs)
|
||||
{
|
||||
Ude.CharsetDetector cdet = new Ude.CharsetDetector();
|
||||
cdet.Feed(fs);
|
||||
cdet.DataEnd();
|
||||
fs.Seek(0, SeekOrigin.Begin);
|
||||
if (cdet.Charset != null)
|
||||
{
|
||||
Console.WriteLine("Charset: {0}, confidence: {1}", cdet.Charset, cdet.Confidence);
|
||||
return System.Text.Encoding.GetEncoding(cdet.Charset) ?? System.Text.Encoding.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
return System.Text.Encoding.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Load(string rawUrl, string sheetName, Stream stream, bool exportTestData)
|
||||
{
|
||||
s_logger.Trace("{filename} {sheet}", rawUrl, sheetName);
|
||||
RawUrl = rawUrl;
|
||||
string ext = Path.GetExtension(rawUrl);
|
||||
using (var reader = ext != ".csv" ? ExcelReaderFactory.CreateReader(stream) : ExcelReaderFactory.CreateCsvReader(stream))
|
||||
using (var reader = ext != ".csv" ? ExcelReaderFactory.CreateReader(stream) : ExcelReaderFactory.CreateCsvReader(stream, new ExcelReaderConfiguration() { FallbackEncoding = DetectCsvEncoding(stream) }))
|
||||
{
|
||||
do
|
||||
{
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ namespace Luban.Job.Cfg.Defs
|
|||
{
|
||||
throw new Exception($"定义文件:{CurImportFile} table:'{p.Name}' group:'{invalidGroup}' 不存在");
|
||||
}
|
||||
p.InputFiles.AddRange(input.Split(','));
|
||||
p.InputFiles.AddRange(input.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrWhiteSpace(s)));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(branchInput))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
||||
<PackageReference Include="NeoLua" Version="1.3.11" />
|
||||
<PackageReference Include="Scriban" Version="2.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue