-1

My input text file looks like on this format

Consignee                                  Documnet No
MANULI DA AMAZONIA                         12345678
INDUSTRIA DE EMBALAGENS LTDA AV.            Export Reference
BURITI 3670 BAIRRO DISTRITO                 44444557
INDUSTRIAL 69075-000 MANAUS, AM             555555555  
  1. First i want read Consignee details

  2. Second i want to read Doucment No details

  3. Export Reference details

My program is running good

Note: I am facing the problem is when I am reading a consignee name I want to extract the text line of the consignee details. But here extracting the document no and export reference details also. So here I want to skip the text line of the document no and export reference details When I am reading consignee Name

My output comes like on this format. When I read consignee Name

Consingee
MANULI DA AMAZONIA 
INDUSTRIA DE EMBALAGENS LTDA AV 
BURITI 3670 BAIRRO DISTRITO
INDUSTRIAL 69075-000 MANAUS, AM
Pang
  • 9,564
  • 146
  • 81
  • 122
Krish
  • 1
  • 3
  • Please post yoor code here – serge1peshcoff Mar 03 '18 at 10:11
  • My program code string text=System.IO.File.ReadAllText(@"D:\text1.txt"); int i = text.IndexOf("Consignee"); string consignee= text.Substring(i+9,110); System.IO.File.WriteAllText(@"D:\output.txt"Consignee"=+consingee); console.Writeline("Consignee="+consingee); console.Read() – Krish Mar 03 '18 at 10:13
  • there is hard coded "Consignee" . if you dont want display header "Consignee". just remove header and display consignee value.for.e.g; console.Writeline(consingee); – user9405863 Mar 03 '18 at 10:14
  • i have to read lot of values in a text file so if i remove the header name how could it possible. – Krish Mar 03 '18 at 10:17
  • HI Hazarath Chillara how to solve this problem? – Krish Mar 05 '18 at 03:54
  • Please edit your question and add your code *there*. Code in comments is unreadable and almost useless. –  Mar 12 '18 at 03:40

2 Answers2

0

If i understood your question correct you want to skip the header. you can try some thing like this

stringReader.ReadLine() /// this will read first line  and don't do any processing .header will be skipped

while ((txtline = stringReader.ReadLine()) != null)
{

/// do your processing 
}
user9405863
  • 1,506
  • 1
  • 11
  • 16
  • there is hard coded "Consignee" . if you dont want display header "Consignee". just remove header and display consignee value.for.e.g; console.Writeline(consingee); – user9405863 Mar 03 '18 at 10:12
  • The problem is on my code when i read consignee header its reading document no and export reference details. so i don't want to read at the of time reading consignee details – Krish Mar 03 '18 at 10:26
-1

I guess you should try to split string and convert it to list to get text you are looking. Like :

string[] data = str.Split(' ');
// str is your main string
// array data contains all your info splitted in array form so you could get 
// Xth member of array like data[X];

Moreover if you know what string will come before or end of your given name then you could easily get text in a string by implementing some methods like : get-string-between-two-strings-in-a-string

Agent_Orange
  • 351
  • 1
  • 13