mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
Added csv-to-text.ps1
This commit is contained in:
parent
6d0a7b8efa
commit
5fdc3cd114
@ -12,6 +12,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
|
||||
* [check-xml-file.ps1](Scripts/check-xml-file.ps1) - checks the given XML file for validity
|
||||
* [clone-repos.ps1](Scripts/clone-repos.ps1) - clones well-known Git repositories
|
||||
* [configure-git.ps1](Scripts/configure-git.ps1) - sets up the Git configuration
|
||||
* [csv-to-text.ps1](Scripts/csv-to-text.ps1) - converts the given CSV file into a text list
|
||||
* [download.ps1](Scripts/download.ps1) - downloads the file/directory from the given URL
|
||||
* [empty-dir.ps1](Scripts/empty-dir.ps1) - empties the given directory
|
||||
* [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps
|
||||
|
26
Scripts/csv-to-text.ps1
Executable file
26
Scripts/csv-to-text.ps1
Executable file
@ -0,0 +1,26 @@
|
||||
#!/snap/bin/powershell
|
||||
|
||||
# Syntax: ./csv-to-text.ps1 [<csv-file>]
|
||||
# Description: converts the given CSV file into a text list
|
||||
# Author: Markus Fleschutz
|
||||
# Source: github.com/fleschutz/PowerShell
|
||||
# License: CC0
|
||||
|
||||
param([String]$Path)
|
||||
|
||||
try {
|
||||
if ($Path -eq "" ) {
|
||||
$Path = read-host "Enter path to CSV file"
|
||||
}
|
||||
|
||||
$Table = Import-CSV -path "$Path" -header A,B,C,D,E,F,G,H
|
||||
|
||||
foreach($Row in $Table) {
|
||||
write-output "* $($Row.A) $($Row.B) $($Row.C) $($Row.D) $($Row.E) $($Row.F) $($Row.G) $($Row.H)"
|
||||
# write-output "* [$($Row.B)](ipfs::$($Row.A))"
|
||||
}
|
||||
exit 0
|
||||
} catch {
|
||||
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user