How to copy first 9 characters and last 26 characters of every line from text file to excel?

Hi Team,

How to copy first 9 characters and last 26 characters of every line from text file to excel
Example :slight_smile:
D103372171033721C12AAG000750 3abcd 124220190802T656IL 20191215 0.40 0.40 0.00 E101AgencyBL is Lockedabcd(Line ends here)
D8002341280023412010100D06ABR003560 3COMM 13420190929B522IL 20191130 200.00 6.00 0.00 E101AgencyBL is Lockedabcd(Line ends here)
D8002313680023136010100D06ABR003263 3COMM 13220190929B522IL 20191130 150.00 4.50 0.00 E101AgencyBL is Lockedabcd(Line ends here)
D8002229280022292010100D06ABR003169 3COMM 13520190926B522IL 20191130 150.00 4.50 0.00 E101AgencyBL is Lockedabcd
D8004703480047034010100D06ABR000272 2COMM 8720190921B522IL 20191130 200.00 6.00 0.00 E101AgencyBL is Lockedabcd(Line ends here)
D8004602480046024010100D06ABR003444 2COMM 9020190924B522IL 20191130 150.00 4.50 0.00 E101AgencyBL is Lockedabcd(Line ends here)

1 Like

@RajeshT

  1. First use Read Text file activity to read the data from text file and will give you output as String and say โ€˜textDataโ€™.

  2. And then split the based on New Line.

       arrTextData [] = textData.Split(Environment.NewLine.TocharArray)
    
  3. And then use ForEach loop to iterate one by row from above array.

    ForEach item in arrTextData
        string1 = item.Substring(0,9)
        string2 = item.Substring(item.Length -26)
3 Likes

Hi @lakshman ,

Am getting below error:


2 Likes

@RajeshT

Could you please print item value using Message Box activity before Assign activity and check once.

2 Likes

Hi @lakshman ,

Here it is:
image

1 Like

Hi @lakshman ,

After displaying first message box,one more empty message box printing am not sure why!

image

1 Like

Hi @lakshman,

First line is printing,when comes to next loop seemd its getting issue.
imageAgentTesting.xaml (63.1 KB)

@RajeshT

Could you please show me screenshot of your data in notepad file.

2 Likes

Check this workflow,GettingStrings.zip (12.0 KB)
@RajeshT

2 Likes

This is working fine @Manish540 .Thanks a ton!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.