How to read a dat file in uipath

Hi All,

i have a challenge, where i need to read a dat file and inside that there are few details is there, but the challenge is i need to read data and save it excel , when i am saving in excel manually it is taking scientific value because some value is more than 15 digit.

Thanks in advance

Hi @RAKESH_KUMAR_Tiwari

Could you try to read the specified file using the Read Text activity & verify once?

Best Regards.

1 Like

Hi,

You can use Read Text File or Read CSV too.
Also, You can follow the below thread:

How to read .dat file? - Help - UiPath Community Forum

Hope this helps…!!

Thanks.

1 Like

When working with data in a DAT file and saving it to Excel, you may encounter issues with scientific notation being applied to large numbers. To prevent Excel from converting the values to scientific notation, you can format the cells in Excel as text before pasting the data. Here’s a step-by-step approach to achieve this:

  1. Use the Read Text File activity in UiPath to read the contents of the DAT file into a string variable.

  2. Create an Excel application scope using the Excel Application Scope activity in UiPath.

  3. Within the scope, use the Generate Data Table activity to convert the string variable containing the DAT file data into a DataTable.

  4. Add a For Each Row activity to iterate through each row in the DataTable.

  5. Within the loop, use the Assign activity to assign the value of each cell to the corresponding Excel cell. Convert the value to a string using the ToString method to ensure it is treated as text.

  6. After the For Each Row activity, use the Write Range activity to write the data from the DataTable to the Excel file.

Here’s an example of the workflow:

Read Text File:
- Input: Path to the DAT file
- Output: TextData (string variable)

Excel Application Scope:
- Input: Path to the Excel file

   Generate Data Table:
   - Input: TextData
   - Output: dataTable (DataTable variable)

   For Each Row:
   - Input: dataTable

      Assign:
      - To: excelCell
      - Value: row.Item("ColumnName").ToString()  // Replace "ColumnName" with the appropriate column name or index

      Write Cell:
      - Input: excelCell

By converting the values to strings before writing them to Excel cells, you can prevent Excel from applying scientific notation. Ensure that the target cells in Excel are formatted as text before running the workflow to retain the original values without scientific notation.

Please note that if you need to perform calculations or further analysis with the data in Excel, converting the values to strings may not be suitable. In such cases, you may need to explore alternative approaches or formats that can accommodate larger numbers without losing precision or converting to scientific notation.

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