Click here to Skip to main content
15,902,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi im pretty new to coding and my problem is this:
i have multible files that looks like this:

XL2 STIPA Reporting: Lundsgaard\2020-04-22_STIPA_003_Report.txt

# Hardware Configuration
Device Info: XL2, SNo. A2A-13445-E0, FW3.33
Mic Type: NTi Audio M4261, SNo. 1415, Factory adjusted
Mic Sensitivity: 18.2 mV/Pa
Time Zone: UTC+00:00

# Measurement Setup
Profile: Full mode
Append mode: OFF
IEC 60268-16: ed4.0 2011

# STIPA Results
Date Time Date Time STIPA CYCLE
[YYYY-MM-DD] [hh:mm:ss] [YYYY-MM-DD] [hh:mm:ss] [STI] [STI]
2020-04-22 08:17:50 2020-04-22 08:18:05 0.52
There is more columns after the Cycle part but i only wants to get to STIPA column.
I think parse the column part, but i cant see how. Rigth now i have used ReadAllText, and guesing its something with ReadLines instead.
Some advice would be really apreaciated, atleas some pointers what way i need to go..

Jonas a beginner on deep water

What I have tried:

//STIPA raport funktion------------------------------------------------------------------------------------------------------------
private void btnSTIPAReport_Click(object sender, EventArgs e)
List<string> stringList = new List<string>();

string[] files = System.IO.Directory.GetFiles(textBoxInput.Text, "*_STIPA_*_Report.txt");

foreach (string file in files)

string resultText = string.Join("", stringList.ToArray());

using (StreamWriter outFile = new StreamWriter(textBoxOutput.Text + "\\Combined STIPA measurements.txt"))
Updated 28-Oct-22 6:23am

1 solution

Use String.Split Method (System) | Microsoft Learn[^] to split the line into tokens. You can then take the relevant field from the line, something like:
// for each line with the fields you want
string[] tokens = string.Split(' ', 6);
string stipa = tokens[4];
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900