How we can convert the data from Excel to Text file

I have an Excel as per shown in below picture, I want to convert the excel into Text file without Header (Not Like CSV i.e. Comma Separated ).

I have tried by using Read range and then Write Text file Activity but it gives me output in Comma separated format.

But I want the output as per in text file (Notepad) as shown below

@Ajinya_jorwekar

.Certainly! To convert an Excel file into a text file without headers, you can follow these steps:

  1. Open Excel File:

    • Open your Excel file.
  2. Save As Text:

    • Go to “File” → “Save As.”
    • Choose a location and select “Text (Tab delimited) (*.txt)” as the file format.
  3. Text Import Wizard:

    • Follow the Text Import Wizard.
    • Choose “Delimited” and click “Next.”
    • Unselect all delimiters except “Tab.”
    • Click “Finish.”

This will save your Excel data as a tab-delimited text file without headers.

@Ajinya_jorwekar

can you try once by using output datatable

output datatable gives you the output as string

and pass that string to write text file

by using UI path how we can do that ?

Hi @Ajinya_jorwekar
You can replace the comma with space & then do the write text file

Str_Output.replace(“,”, " ")

Hi @Ajinya_jorwekar ,
Thanks for reaching out to UiPath community.

You can try these steps.

  • Read Excel File:
    • Use the “Excel Application Scope” activity to open the Excel file.
    • Use the “Read Range” activity to read the data from the Excel sheet into a DataTable.
  • Remove Header:
    • Use the “Remove Data Row” activity to remove the first row (header) from the DataTable.
  • Write Text File:
    • Use the “Write Text File” activity to write the data to a text file.
    • In the “Write Text File” activity, provide the path where you want to save the text file.
    • Set the content of the text file using String.Join(Environment.NewLine, dt.AsEnumerable().Select(Function(row) String.Join(" ", row.ItemArray))) where dt is your DataTable.

Regards,
@pratik.maskar

Hi @Ajinya_jorwekar

// Read Excel File
Read Range activity:
ExcelFilePath: “Path\to\your\ExcelFile.xlsx”
Output : YourDataTable

// Remove Headers
Assign activity:
YourDataTable = YourDataTable.AsEnumerable().Skip(1).CopyToDataTable()

// Write to Text File
Write Text File activity:
File Path: “Path\to\your\TextFile.txt”
Text: String.Join(Environment.NewLine, YourDataTable.AsEnumerable().Select(Function(row) String.Join(" ", row.ItemArray)))

Hi @Ajinya_jorwekar ,
Use output data table activity to convert datatable to string.
Reference

After that using write text file* activity you can write into text file.
Reference

regards,