Get Information from File

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Posts: 1
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Fri May 10, 2019 8:02 am

Get Information from File

Post by luckydead »

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
Or simply columns are like this:
Capture.PNG (11.35 KiB) Viewed 977 times

File Example.csv
(9.29 KiB) Downloaded 37 times
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:
Capture2.PNG (5.11 KiB) Viewed 977 times
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

write-host "Please Drag and Drop your CSV in the console Window and press enter"
$input  = read-host "Source"

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"
if(-not($ouput) -or (test-path $ouput)){$output = "C:\Users\$name\desktop"}

    import-csv $input -ErrorAction Stop | Export-Csv $output -Delimiter "," -ErrorAction Stop
    write-warning "Please contact support and provide the following error message"
    write-host " Support email: myemail " -ForegroundColor Blue -BackgroundColor White
    read-host "Press ENTER to exit"

Posts: 14448
Joined: Tue May 22, 2007 9:57 am

Re: Get Information from File

Post by jvierra »

You seem to be asking for someone to write a script for you. Custom script writing is beyond the scope of most technical forums.

I suggest that a good place to start would be to learn basic PowerShell. This will help you to ask your question in an understandable way and get you started on writing your own scrips.

Here are some learning resources to help you get started. ... _polymer=1 ... 2304984382

You can also use the PowerShell help to get more information on how to use specific CmdLets:

help import-csy -online
help Select-Object -online

Good luck.