0

id made a process in powershell using export-csv that works correctly, except when i set the option to filter the column content. Obviously the error is in the syntax that I am using in the "where".

If I remove the "where" statement the file is generated correctly. The data contained in this column is of type "2.2", so it is enough for me to filter that the value contains a ".".

Could someone help me to solve the problem and that the values ​​that contain "." ?

Get-ChildItem "D:\Proceso_RDA\in\OSC_UAS\" -Filter "PM_IG500020_15*.csv" | %{Import-Csv $_.FullName -Header DeviceID,DeviceName,ResourceName,CollectionTime,GranularityPeriod,CRC4BBE,CRC4ES,CRC4SES,CRC4FEBBE,CRC4FEES,CRC4FESES,CRC4UAS,CRC4CSES,CRC4FECSES,CRC4FEUAS,OSC_BBE,OSC_ES,OSC_SES,OSC_UAS -Delimiter ',' |Select-Object -Skip 2} | Select "DeviceID","CollectionTime","OSC_UAS" | where OSC_UAS -eq "*.*" | Select-Object -Skip 2 |  Export-Csv D:\Proceso_RDA\out\OSC_UAS\OSC_UAS_Procesado_$env:Path.csv -NoTypeInformation

Corretly sintaxis of where statment

1
  • This seems very excessive since you're importing the csv's and specifying the headers just to select 3 of them. Then you filter outside of the loop when you couldve done that inside. -eq is looking for an exact match (sorta - since it's not case sensitive by default). So use -Like as the operator instead. Nov 30, 2022 at 22:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.