Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hi all,
 
I am reading .txt file in c#. I have one problem like my txt file contain more then 2000 lines and it will take lots of time to execute because currently i am read line by line and use sub-string function for split data. Each line contain one employee detail. In line i get data into fix position like,
Employee Name     = 0 to 50 Character,
Employee Address  = 51 to 200 Character,
Employee BDate    = 201 to 215 Character,
Employee Gender   = 216 to 220 Character
etc..
 
Is there any technique to read line and split it to array or something else with this field? I want to improve performance.
Posted 18-Mar-14 20:58pm
Comments
Sergey Alexandrovich Kryukov at 19-Mar-14 2:09am
   
Why? Why fixed-size? Array of what? Why do you think it would improve performance?
But I can tell you in advance: such data structure and code design don't make sense.
If you explain your ultimate goals, you may have a chance to get some practical advice.
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes it seems you're looking for this one http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser(v=vs.110).aspx[TextFieldParser]
 
it support fixed with fields without having to substring it yourself
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 132
2 ProgramFOX 130
3 Maciej Los 105
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 19 Mar 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100