I'm trying to figure out is there a way to read CSV file in Powershell
and import in cell 1 column 1 the data -"machine name" to get the
monitor serial number ?
Right now I have this code in which I manually replace the machine name (Station01) with the monitor serial number and then I copy the serial number and paste it into the csv file.
I'm hoping the that Csv file can be used to record multiple monitors for each serial number on the columns.
Example, 4 or 5 lines one for each machine containing the serial numbers 2 or 3 monitors.
This I want to achieve using a Powershell script -
Get input list of machine name on csventer code here run the report and see the serial number on it
Earlier we were using vb script that used to work.
But it doesn't work for some reason now.
Please help me with such Powershell script?
Related
I'm trying to insert retrieved values into an existing CSV by using -Append -Force. However, it does not place it under the rows that I wanted it to. Anyway to solve this? Currently, the values are in row 12 to 17, but I want it to be in row 2 to 11. Column A to F are in an existing CSV while column G is what I want to input the values into.
Here is my current CSV output
Expected Output that I'm looking for:
And here is my current Powershell code:
Current Powershell code
I am writing a Powershell script that compares the number of rows in 2 parquet files that are created each hour to monitor the number of rows etc.
I have found the Parquet.NET project, but since all I want to do is query the count of rows, I wonder if this is overkill. Is there a module for parquet?
I have to combine a lot of files , mostly CSV, already have code to combine however I need first to trim the desired csv files so I can get the data that I want. Each CSV has first 2 columns of 8 rows which contain data that I want. and then just below those there is a row that generates 8 columns. I am only having issue grabbing data from the first 8 rows of the 2 columns.
Example of the csv first 3 rows:
Target Name: MIAW
Target OS: Windows
Last Updated On: June 27 2019 07:35:11
This is the data that I want, the first 3 rows are like this, with 2 columns. My idea is to store the 3 values of the 2nd column each into a variable and then use it with the rest of my code.
As I only have a problem extracting the data, and since the way the CSV are formated there is no header at all, it is hard to come up with an easy way to read the 2nd column data. Below is an example, this of course will be used to process several files so it will be a foreach, but I want to come up first with the simple code for 1 file so I can adapt it myself to a foreach.
$a = MIAW-Results-20190627T203644Z.csv
Write-Host "$a[1].col2"
This would work if and only if I had a header called col2, I could name it with the first value on the 2nd column but the issue is that that value will change for CSV file. So the code I tried would not work for example if I were to import several files using:
$InFiles = Get-ChildItem -Path $PSScriptRoot\ *.csv -File |
Where-Object Name -like *results*
Each CSV will have a different value for the first value on the 2nd column.
Is there an easier way to just grab the 3 rows of the second column that I need? I need to grab each one and store each in a different variable.
I am trying to create a powershell script which is based on csv file for metadata, I have defined a column Frequency with a number in it.
for example :
PageName FrequencyMonths Email
Page1 3 security#company.com
Page2 6 HR#company.com
I want to know a way that my powershell runs the code whenever the next frequency date is.
The script I have takes input from csv with above like information and runs a a scheduled task "Daily" to send emails to above people at the.
I want to schedule my PS script to run daily however send email only after 3 months to the security team (every after 3 months) and every 6 months to the HR team
Please suggest
Expected result is to send mails to respective teams based on the frequency of months - using a daily running windows scheduled task
Your current script sets $EmailDate to today + x Month. But everytime the script is run and without saving the value anywhere... You should create another column with the date of the next execution.
If( (get-date).date -le $row.NewColumn ){
# sent the mail
# replace $row.NewColumn with (get-date).Date.AddMonths($Frequency)
}
when you are done export the csv to replace the old one.
I have an excel-file which consists of about roughly 10,000 rows and has a size of around 800KB
When I try to import the data to MATLAB both with GUI import tool, or using XLSREAD I get the following message:
Could not open the spreadsheet. MATLAB reported the following error:
XLSREAD unable to read sheet "Sheet1"
File contains unexpected record length. Try saving as Excel 98
I tried saving as excel 98, but didn't help?...funny thing is, I can import other excel-files which are bigger than 10,000 rows and 800KB in size?!...
Ideas? =) My excel-file shouldn't consist anything special, just columns of numeric data with headers consisting of text...
UPDATE !
It seems this only comes when I use MATLAB in Ubuntu 12.10...When I tried it in Windows XP it works just fine....??
I know some time has passed, but I had the same problem with Ubuntu 16.04 and MATLAB R2016a . In my case it didn't worked to delete the columns.
My solution was to change the excel file from .xls to .xlsx and try it with xlsread again (of course with changed path).
Please don't ask me why it works if it's saved in an Microsoft format.
Try removing any empty columns / rows you have in your sheet, as well as explicitly delete several columns / rows after your data. Matlab seems to have a problem with "empty" columns / rows.