Last active
June 14, 2020 04:23
-
-
Save xhlove/b409a09e965665acf52abf2ed6773cb7 to your computer and use it in GitHub Desktop.
xlsx粘贴到txt文件中的数据,补充数据后转换到csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = "path/to/paste/file" | |
$height = -2.333 | |
$results = Select-String -Path $args -Pattern '(\d+[ |\t]{1})?(-?\d+\.?\d+)([ |\t]{1})(-?\d+\.?\d+)' -AllMatches | |
$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition | |
$ScriptPath = $ScriptPath + '\' + [System.IO.Path]::GetFileNameWithoutExtension($args) + '.csv' | |
$results | foreach{ | |
$newline = "{0:0.000000},{1:0.000000},{2:0.000000}" -F [Double] $_.Matches[0].groups[2].value, [Double] $_.Matches[0].groups[4].value, $height | |
$newline | Out-File -Encoding UTF8 -Append $ScriptPath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment