I'm new to powershell and I have one task to make at home.
Can someone really help me out with this because I cannot do it myself , that's why I will ask for some help.
What i want to have :
1. When open powershell file ( To start by asking "Drag or drop the file" or put location to the file
2. Only to open .csv files format
3. When open the file to get from the file this lines. (Here is example a few lines inside the file)
Example.csv :
Code: Select all
A0003979305I606 560BLSA14_C418_1A 20190508 55450 20190508 60008 300SB601
A0003979030I606 560BLSA14_VG20_1A 20190508 60122 20190508 60415 300SB601
A0003979320I606 560BLSA14_VG20_1A 20190508 60500 20190508 60909 300SB601
File Example.csv What i really need to do when open the file .csv
1. To get information from columns only : A , E , F, H , I
2. To save the information in another file (Default ./result.csv)
3. To make a little change in columns
Example: 20190508 55450 20190508 60008 300SB601 (first row)
To be saved inside the file like this:
2019.05.08 05:54:50 AM 06:00:08 AM 300SB601
Also to be added 1 new column that will count the results from 06:00:08 - 05:54:50 (this is the time from start and finish) so we will get how much time needed to finish result (05:18)
And result inside the file result.csv to be like this: Can someone really help me about this , i know its big work and i'm sorry that i cannot make it myself.
Hope there is some nice person that can help me out.
Thank you very much.
Here is simply what I have for start:
Code: Select all
clear-host
write-host "Please Drag and Drop your CSV in the console Window and press enter"
$input = read-host "Source"
clear-host
write-host "Please enter your export path"
write-host "The default output location is your desktop [$($env:userprofile)]" -ForegroundColor Yellow
write-host "Leave the input blank for the default location and just press ENTER" -ForegroundColor Yellow
$output = read-host "Output Location"
$name=($env:UserName).tolower()
if(-not($ouput) -or (test-path $ouput)){$output = "C:\Users\$name\desktop"}
try{
import-csv $input -ErrorAction Stop | Export-Csv $output -Delimiter "," -ErrorAction Stop
}
catch{
write-warning "Please contact support and provide the following error message"
$error[0]
write-host " Support email: myemail " -ForegroundColor Blue -BackgroundColor White
read-host "Press ENTER to exit"
}