(CSV - Excel) Convert CSV file to an .xlsx

how to convert csv format file into xlsx

Admin note: Please use always the appropriate category when posting a topic (this shouldn’t be in the “Uncategorized” section), along with an appropriate title.

You can read the contents of the .CSV file using one of the .ReadCSV actions.
The output of these actions is a data table. Look here:
https://robin-language.org/docs/robin-the-rpa-language/standard-modules/file/

After that you can write the extracted data table to an excel instance.
You can do that by creating a loop that iterates the data table, one position at a time and writes the data to a specified position (I am thinking of a 1-1 approach) to the excel instance using the Excel.WriteCell action. Look here:
https://robin-language.org/docs/robin-the-rpa-language/standard-modules/excel/

Best regards,
J.

2 Likes

If you have a CSV file already and you don’t need to write it into an existing Excel worksheet, but rather a new one, maybe this’ll make your life easier.

Screenshot:

Capture

Code:

file.ReadCSV \
    CSVFile:  "C:\Users\you\Documents\Robin\9.2\forum\csvtest.csv" \
    Encoding:File.CSVEncoding.UTF8 \
    TrimFields:True \
    FirstLineContainsColumnNames:False \
    ColumnsSeparator:File.CSVColumnsSeparator.SystemDefault \
    CSVTable=> CSVTable

Excel.Launch \
    Visible:True \
    LoadAddInsAndMacros:False \
    Instance=> ExcelInstance

Excel.Write \
    Instance:  ExcelInstance \
    Value: CSVTable

CSV file:

John,Doe,Hospitality,Janitor,Level one
Veejay,Singh,HR,Manager,Level five
Herbert,Meuller,Engineering,Tech,Level three

Output:

output

Best regards,
burque505

2 Likes