1

I'm trying to get from this file ->

File 1:

Name;Datum;Nominal;L_TOL;U_TOL;Value;Unit;Feature;low nat. Border;Type;No.;Date;Time;Operator

abstrich_;;   0.00;   0.00;   0.00;   0.02;mm;0;0;9315;1;16.03.23;14:59:02;xy
abstrich__;;   0.0;   0.0;   0.0;   0.2;mm;0;0;9315;2;16.03.23;14:59:02;xy
mp_658__;;   0.000;   0.000;   0.480;   0.164;µm;0;2;100;3;16.03.23;14:59:02;xy
rough01_Pt;;   0.000;   0.000;   0.810;   0.389;µm;0;2;9350;4;16.03.23;14:59:02;xy
rough02_Rz;;   0.000;   0.000;   0.500;   0.264;µm;0;2;9350;5;16.03.23;14:59:02;xy

to this format ->

File 2:

abstrich_;0.02
abstrich__;0.2
mp_658__;0.164
rough01_Pt;0.389
rough02_Rz;0.264

I don't know how to extract these two values and merge in one line.

I need a solution with Import-Csv which let me bring the first file in the second format.

4

1 Answer 1

2

This command does output the specified data to file if you want headers:

Import-Csv -Path "test.csv" -Delimiter ";" | Select Name,Value | Export-Csv -Path "test2.csv"

You import the CSV to an object list, then select only specified properties and save them to another CSV.

And this one can be used if you want no headers as in example:

(Import-Csv -Path "test.csv" -Delimiter ";" | Select Name,Value | ConvertTo-Csv -NoTypeInformation) | Select -Skip 1 | Set-Content -Path "test2.csv"

Here you again import the CSV and select only specified properties, then you need a workaround of converting to CSV format and skipping the 1st row of the full content. And you output the resulting content as CSV.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.