Hi all ive been trying to convert my csv to an xlsx for a while now. Im unable to use the conventional method as i meet the error getting error on read csv line 6 contains more values than the header line. As such i tried to use the read range function to read the values i want, but am encountering issues.
The error i get is that my csv file is not existent in my FormSGOutput workbook, but the point is that its a blank workbook, i want to read the range in my current csv file and output to a datatable, and then output it to the workbook itself.
Any help would be appreciated.
→ Use Read CSV activity to read the data from CSV file and it will give output as DataTable. Let’s say dtInput.
->And then use Write Range Workbook activity and pass above output DataTable dtInput to write into Excel file.
Hi sorry but i am unable to use the Read CSV activity because of the format of my CSV file. As a reference, i am encountering the same scenario as this person.
The only issue is i need help with the formatting for the structure as shown above in my screenshot.
Hi sorry but i am unable to use the Read CSV activity because of the format of my CSV file. As a reference, i am encountering the same scenario as this person.
The only issue is i need help with the formatting for the structure as shown above in my screenshot. So im looking to solve the issues using this instead.
Here’s how to convert a CSV file to an xlsx file using UiPath Studio:
Using Read CSV and Write Excel Activities**
This method involves reading the CSV data and writing it to a new Excel file.
Drag and drop a “Read CSV” activity onto the workflow designer.
Set the “File Path” property to the path of your CSV file.
Optionally, configure other properties like “Headers” (if the first row contains column names) and “Delimiter” (if different from comma).
Drag and drop a “Write Excel” activity after the “Read CSV” activity.
Set the “File Path” property to the desired path and filename for the output Excel file (e.g., “Output.xlsx”).
Set the “Sheet Name” property to the name of the worksheet in the Excel file (optional, defaults to “Sheet1”).
Connect the “Read CSV” activity to the “Write Excel” activity. The output from “Read CSV” (usually named “dt_Result”) will be used as input for “Write Excel.”
Run the workflow. This will read the data from the CSV file, create a new Excel file, and write the data to the specified sheet.
I am unable to reformat the csv even though i know its format has issues. The only 2 ways i am able to use is to either read.txt file or read range. Below ive attached the link to the documentation for the explanation for read range and it shows that read range can be used for.csv files as well.
Due to sensitive info we cant show the data info below, but as you can see the first few rows 1 to 5 are shorter and i want to only start reading from a6 onwards, but due to the nature of the document, i cannot delete the contents, so im currently looking for a solution. Thanks
Hi Thanks for the suggestion. I have read the file as a .txt, but i want to filter such that i only collect text from the start of row6 and column D normally in an excel file or CSV, how can i achieve this result now that its a .txt file?
Then you can just use Read CSV to read the destinationFile. Once you have it in a datatable you can remove columns you don’t need and do whatever else you want with it.
The error is because those column names don’t exist in the datatable.
Also, you’re on the wrong tab in Filter Data Table. That tab is to remove rows. Go to the Output Columns tab and either list the columns to keep, or set it to remove and list the columns to remove.
Also, you don’t have to use a bunch of different datatable variables. You can put the same datatable as your input and output for Generate Data Table and Filter Data Tabl.
Hi postwick,
The issue encountered is the filtering is improper, which results in the output being inaccurate and unable to trace the columns. When checking what exactly is inside the data table, it seems that theres an error in the formatting somewhere, which was already present before the filtering into a data table itself.
Can you post the text file so I can look at it? Looks like you’re not properly removing the lines at the beginning, so you’re not ending up with the headers on line 1. I suggest using the expression I gave you instead of Split.
due to confidential information in the columns, we are unable to show the data, but from here, it seems that the column headers have split into four different lines, as for the expression you have given, ill give it a shot but the split worked fine during testing.
That just looks like word wrap making it go to the next line, not actual linefeeds.
And that’s not CSV data, that looks like fixed length. You have to designate it that way in the Generate Data Table and give it the length of each column.
hi @Benjamin1 ,
You can use Readrange inside Excel scope to read CSV file then write datatable to other excel file
Or try convert by VB code
Could you share your file, I will try it