C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Assemblies
.NET Core
.NET Standard
Active Directory
ADO.NET
Agile Development
AJAX
Alexa Skills
Algorithms in C#
Android
Angular
Architecture
ArcObject
Artificial Intelligence
ASP.NET
ASP.NET Core
Augmented Reality
Aurelia
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blockchain
Bootstrap
Bot Framework
Business
C#
C# Corner
C, C++, MFC
Career Advice
Chapters
CIO
Cloud
COBOL.NET
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Cortana Development
Cryptocurrency
Cryptography
Crystal Reports
Current Affairs
Custom Controls
Cyber Security
Data Mining
Databases & DBA
Design Patterns & Practices
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
Expression Studio
F#
Files, Directory, IO
Games Programming
GDI+
General
Generative Engine Optimization (GEO)
Google Cloud
Google Development
Graphics Design
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Internet & Web
Internet of Things
Ionic
iOS
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
kotlin
Leadership
Learn .NET
LightSwitch
LINQ
Machine Learning
Microsoft 365
Microsoft Office
Microsoft Phone
Mobile Development
Multithreading
Nano Banana
NetBeans
Networking
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Power BI
Printing in C#
Products
Progressive Web Apps
Project Management
Python
Q#
QlikView
R
React
Reports using C#
Robotics & Hardware
Ruby on Rails
Salesforce
Security
Servers
SharePoint
SignalR
Silverlight
Smart Devices
Software Testing
SQL Language
SQL Server
Startups
String in C#
Swift
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
WCF
Wearables
Web Development
Web Services
Web3
Windows 10
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML Standard
XML
XNA
XSharp
Register
Login
3
Answers
Read a text file _including some column based data in c#
yamid
15y
3.8k
0
1
Active Directory
Reply
The data file is as follows which includes 1. a description line(starts with *SUMMARY of...*) 2.The names of each column 3.four lines which are not needed to be read(they may include some numbers but we donot care) 4.few space lines(not known how many-we should skip them-) 5. and the data columns respresentative of each name(in line 2).
I want to read each column of data into an array with the name in line 2.
--note: 1. The begining of each section is started with string "SUMMARY" which helps that after this line the data should be read. Before SUMMARY string there may be an empty line.
--note: 2. If there a name-like DATE or CPR- is repeated we should change the name to DATE1,DATE2,.. and CPR1,CPR2,...
--note: 3. All Data EXCEPT *DATE* are of type DOUBLE so all data are type DOUBLE except the columns for DATE.
I wonder if it is it possible to to" look for one the data column once a time" represent each name. for example I want to look for data corresponding to CPR2[] or COPR2[],... once a time. I mean each time I need an array, it should opens the text file and searches for that specific name and obtain the data column needed.
For example if I need CPR2, it searches for second CPR find in the file an read the corresponding data.
Well, it is becomming quite long, sorry for that. I wonder is someone kindly helps.
------------------------------------------------------------------------
...
SUMMARY OF RUN contineous_shale
DATE FLPR WOPR WOPT WWCT WLPR WTHP WOGR WGPR WWPR
STB/DAY STB/DAY STB STB/DAY PSIA STB/MSCF MSCF/DAY STB/DAY
WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A
01-JAN-2000 0 0 0 0 0 0 0 0 0
01-JAN-2000 1004.796 980 0.0098 0.024678 1004.796 0 2.857143 343 24.79598
...
SUMMARY OF RUN contineous_shale
DATE COPR CPR CPR CPR CPR CPR CPR CPR CPR
STB/DAY PSIA PSIA PSIA PSIA PSIA PSIA PSIA PSIA
WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A WELL-A
28 28 25 28 28 1 28 28 2 28 28 3 28 28 4 28 28 5 28 28 6 28 28 7 28 28 8
01-JAN-2000 0 2389.568 2391.734 2393.899 2396.064 2398.23 2400.396 2402.56 2404.728
01-JAN-2000 46.57573 2341.398 2343.578 2345.758 2347.938 2350.117 2352.297 2354.477 2356.656
01-JAN-2000 46.79882 2336.025 2338.204 2340.383 2342.562 2344.74 2346.919 2349.098 2351.277
01-JAN-2000 46.92634 2331.071 2333.25 2335.429 2337.608 2339.786 2341.965 2344.144 2346.322
...
--------------------------------------------------------------------------
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Post
Reset
Cancel
Answers (
3
)
Related Discussion