Skip to content

Instantly share code, notes, and snippets.

@xhlove
Last active June 14, 2020 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xhlove/b409a09e965665acf52abf2ed6773cb7 to your computer and use it in GitHub Desktop.
Save xhlove/b409a09e965665acf52abf2ed6773cb7 to your computer and use it in GitHub Desktop.
xlsx粘贴到txt文件中的数据,补充数据后转换到csv
$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