How do i read each row with dynamic row and column and convert to text file

dear sir

i need some help as i am only 2 weeks on UiPath.

I have an excel sheet with the following data. i need to convert each row to individual text file based on the number of rows.

After conversion the 1st text file will look like the below:-

First: 1
Second: 2
Third: 3
Fourth: 4

The 2nd text file will look like this below:-

First: 5
Second: 6
Third: 7
Fourth: 8

There are 2 text files as there are only 2 rows in this example but the row and column can grow unlimited. Also after creating each text file the system will need to add a additional column at the end of the column to indicate it “completed” so that in the next round the system will not read those with the “complete” Status.

could some gurus please help as i am stuck. what i am getting now is the below which is not the correct format:-

I tried attaching all the screen shot but i got an error message that says “new users an only attached 1 image” :frowning:

thank you
subas

Sorry this is how my excel source file is.

Annotation 2020-03-26 171720

Dear all.

This is what i am getting now:

Annotation 2020-03-26 170857

Thank you

Dear all.

This is what it should be:

Annotation 2020-03-26 170331

Thank You
Subas

@subasc

  • read excel through read range activity and put into datatable
  • then through for each row activity you can read each row
  • under for each row activity , you can write txt file with columns name and value .
    Use append file for insert data

hi @sandeep13

Thank you for the steps. can you indicate based on the attached screenshot what is wrong as i still can’t get the correct format as i want

i think my write to text format is wrong.

Regards
Subas

1 Like

@subasc
image

DTRecord.Columns(0).ColumnName +":"+row(0).ToString+Environment.NewLine +
DTRecord.Columns(1).ColumnName +":"+row(1).ToString+Environment.NewLine+
DTRecord.Columns(2).ColumnName +":"+row(2).ToString+Environment.NewLine+
DTRecord.Columns(3).ColumnName +":"+row(3).ToString+Environment.NewLine

hi @ Sadeep13

Thank you and the output work fantastic. just on last item, based on the code below where to i put in the .txt so i can then open the file using notepad?

image

Currently the file are generated as per below where there is no .txt extension.

image

Thank you
Regards
Subas

Dear @sandeep13

Could you help on my question above please?

Regards
Subas

@subasc
Put in .txt extension after tostring like that
tostring+".txt" in first box

Dear @sandeep13

Thank you so very much for all the assistance. Everything you have explained worked perfectly.

Once again thank you very much

Regards
Subas

1 Like

@subasc
Always Happy to help

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