in Education by
Hi Folks i was googling one more hours.i did not find anything relevant, I have text File like this S.No Code L Description Interaction Text 1 xxxx x xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2 xxxxxx x xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx 3 xxxx x xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx 4 xxxxx x xxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx 5 xxxxxx x xxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxx xxxxxxxxxx xxxxxxxxxxx xxxxx 6 xxxxxx x xxxxxxxxxxxxxxxx xxxxxxxx xxxxx xxxxxxx xxxxxxxxxx xxxxxxxx xxxxxxx i was Successfully reading all contents using this code, string path = @"c:\temp\MyTest.txt"; string[] lines = File.ReadAllLines(path); but i was stuck when split to columns.any help would appreciated IN short how do i split every columns using fixed length of the string? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Going to cut your example to save time: S.No Code 1 xxxx x 2 xxxxxx x 3 xxxx x 4 xxxxx x 5 xxxxxx x 6 xxxxxx x First define the max lengths of each column, in my example: List maxLengths = new List { 2,7,4}; List> columns = new List>(); // this is where we'll save the columns Iterate over your lines and use the lengths to know which part of the substring to cut off: foreach (string line in lines) { List linesColumns = new List(); int lastIndex = 0; foreach (int maxLength in maxLengths) { linesColumns.Add( line.Substring(lastIndex, maxLength)); lastIndex += maxLength; } } Obviously simplified, you'll have to work on error handling.

Related questions

0 votes
    If I am trying to determine the read speed of a drive, I can code a routine to write files to a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    Is there a built in dll that will give me a list of links from a string. I want to send in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    read the data from employee. text file and sort on age using counting sort,merge sort,quick sort and write ... sortedemponage.txt'. Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    I want create expression with reflection in c#. I am target script is: using (var service = new ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I built an OCR application which reads PDF files and OCR's them. I built it using Multi-threading ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I have 2 Tables, Receipts which contains columns like Id, InvoiceId etc and Invoices, which Contains Id, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    I have 2 Tables, Receipts which contains columns like Id, InvoiceId etc and Invoices, which Contains Id, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Designing a registration form, and I get this error when adding in MessageBoxButtons and MessageBoxIcon. The error ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    F# allows constraining generic types on the type's members, similar to: type ClassWithMemberConstraint = class end ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Is there any simple way to repeat code in a try/catch block after an exception occurs without using method ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am a very novice C# person so please dont be too hard on me Im trying to make a post request ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have a dataset, "AllEventData", and in that dataset is (for the moment) only one table called ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Im facing a litle problem in Deserializing BsonDocuments type, I couldn't find the reason, but I have some ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    How do I implement a Copy menu item in a Windows application written in C#/.NET 2.0? I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
...