正确批次的 csv 过滤器

正确批次的 csv 过滤器

我已经编写了一个批处理脚本,该脚本逐个过滤 CSV 文件特定列中的值并将它们存储在 result.csv 中,批处理代码如下。假设以下是 CSV 文件:

@echo off
(
for /f "usebackq tokens=1-22 delims=%%,. " %%A in ("combined.csv") do (

if %%~C%%~D geq 300 if %%~C%%~D leq 700 if %%E gtr 50 if %%F gtr 100 if %%G gtr 100 echo %%A,%%B,%%C.%%D%%,%%E%%,%%F,%%G%%,%%H.%%I,%%J.%%K,%%L,%%M,%%N.%%O,%%P,%%Q,%%R.%%S,%%T.%%U%%,%%V )

)>>result.csv


:: %%P.%% = 16 = B-QV
:: %%Q.%% = 17 = S-QV
:: %%R.%%S = 18 & 19 = P/E
:: %%T.%%U%% = 20 & 21 = L4Q DY
:: %%V = 22 = Sector

我必须过滤 Chg% 3% 到 7%、B% 大于 50%、Trans 大于 100 以及 Vol/VMA Chg% (5) 大于 100。

但是最后一个过滤器的问题在于它显示错误的数据,尤其是部门数据,因为部门数据带有字符(例如电信和媒体)和字符,而 B-QV 和 S-QV 有时末尾有一个点(例如 1361794.0)。P/E 和 L4Q DY 带有破折号 - 表示没有数据,有时有数据。我该如何解决这个问题?有人能告诉我正确的批号吗?

这是我需要过滤的 CSV 文件:

"Code","Stock","Chg%","B%","Trans","Vol/VMA Chg% (5)","Last","VWAP","S-Issued","Trend","Buy","B-QV","S-QV","P/E","L4Q DY","Sector" 
"694724","DIGI-C24","+1200.000%","83%","27","115%","0.065","0.0760","50000000.00","SSSSSSBS","0.055","5500.00","6000.00","-","-","Telecommunications & Media" 
"688837","AXIATA-C37","+100.000%","51%","8","4428%","0.120","0.1236","50000000.00","SBBBBBSB","0.120","6180.00","12500.00","-","-","Telecommunications & Media" 
"694727","DIGI-C27","+90.909%","0%","1","0%","0.105","0.1050","35000000.00","S","0.095","47500.00","50000.00","-","-","Telecommunications & Media" 
"688835","AXIATA-C35","+83.333%","59%","24","978%","0.165","0.1648","35000000.00","SSBSSBBB","0.160","80000.00","82500.00","-","-","Telecommunications & Media" 
"0138","MYEG","+6.429%","60%","2526","124%","1.490","1.4627","3606305993.00","SSBBBBBB","1.490","569776.00","858900.00","26.86","0.34%","Technology"

相关内容