I have got an input in a CSV file ( not Excel ) which I have got into a sequence through read CSV and achieved an output (output panel) but I am not sure how to add these output into CSV (not Excel) as an additional column.
If I am doing a write CSV activity then it is picking only the last row but I am looking to add a column to my CSV (notepad) which will have all the records available in output
Hi @dipon1112000
First Extract Data
the Extract Activity- See Property And Output Create Variable On DataTable
Write Range In Workbook To Wite Data Table in Excel
see like that
And
Simple
Thanks in advance,
Darshit
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 7:17am
3
Hi @dipon1112000
Try the below process:
=>Use Read CSV to red the file and store the output in a datatable.
Input:
=> Use Build Data Table activity to write the columns.
Build DataTable:
=> Use For Each row in DataTable to iterate through each row and give the below syntax in assign activity:
Number1= CDbl(CurrentRow("column3").ToString)
Number2= CDbl(CurrentRow("Column5").ToString)
Output= (Number1/Number2).ToString
Note: Number1 and Number2 are of DataType System.Double. Output is of DataType System.String
=> Use Add Data Row to add the rows to the datatable.
=> Use Write CSV to write the Datatable back to excel.
Output:
Workflow:
xaml:
Sequence9.xaml (13.6 KB)
Hope it helps!!
Regards
2 Likes
Thanks but I do not have Excel and cannot use Excel, so will I be able to get the data if I give the path to notepad
Anil_G
(Anil Gorthi)
January 6, 2024, 1:37pm
5
@dipon1112000
First of all you want to add a column or row?
If column then read data and use add column then write data back
If row then read data then add data row and then write back
Cheers
This is an error I am getting
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 2:40pm
7
Hi @dipon1112000
Please check the solution I have provided above.
Regards
Thanks for your help, I have followed the same steps but not sure y I am getting this error
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 2:52pm
9
Hi @dipon1112000
Give the below syntax in Add Data Row:
{CurrentRow(0).ToString,CurrentRow(1).ToString,CurrentRow(2).ToString,CurrentRow(3).ToString,CurrentRow(4).ToString, Output}
Pass the same syntax.
Regards
Thank you but now I am getting another error
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 2:59pm
11
@dipon1112000
Could you share the screenshots of whole process. or Send the workflow file.
Regards
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 3:19pm
14
Hi @dipon1112000
You haven’t give the output for Build Data Table. Give the below way by creating a variable out_dt.
Pass the datatable in Add Data Row activity i.e., out_dt:
In Write CSV pass the same datatable out_dt.
Regards
Thank the fraction is showing in output but it’s not getting added to the output file
Only first 2 columns are getting transferred but remaining 4 columns are not
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 3:32pm
16
@dipon1112000
Where do you want to write the output is it in a CSV file or a Notepad file. Specify.
Regards
Notepad.csv as I I do not have Excel that 8sbthe reason I am picking input from notepad.csv and I am supposed to get output to notepad.csv
vrdabberu
(Varunraj Dabberu)
January 6, 2024, 3:43pm
18
Hi @dipon1112000
Try the below process:
=>Use Read CSV to red the file and store the output in a datatable.
Input:
=> Use Build Data Table activity to write the columns.
Build DataTable:
=> Use For Each row in DataTable to iterate through each row and give the below syntax in assign activity:
Number1= CDbl(CurrentRow("column3").ToString)
Number2= CDbl(CurrentRow("Column5").ToString)
Output= (Number1/Number2).ToString
Note: Number1 and Number2 are of DataType System.Double. Output is of DataType System.String
=> Use Add Data Row to add the rows to the datatable.
{CurrentRow(0).ToString,CurrentRow(1).ToString,CurrentRow(2).ToString,CurrentRow(3).ToString,CurrentRow(4).ToString, Output}
=> Use Write CSV to write the Datatable back to excel.
Output:
Workflow:
zip file:
FOrum CSV Task.zip (48.6 KB)
Please do un-zip the file and delete Forum CSV Output and run the process. This will work for you.
Regards,
Thank you you nailed it
Last thing can’t we make the output fraction small
Ex suppose after division if we are getting output as 123.56789 to 124
1 Like
vrdabberu
(Varunraj Dabberu)
January 7, 2024, 12:47am
20
Hi @dipon1112000
If you want to make the output fraction small you can try the below two ways:. Pass any one of the syntax in the Output variable.
1st Way:
Output= Math.Ceiling((Number1/Number2)).ToString
Output:
2nd Way:
Output= Math.Round((Number1/Number2)).ToString
3rd way:
Output= ((Number1/Number2)).ToString("F2")
Pass any one of the three syntaxes in Output variable assign activity inside For Each row in DataTable. I think first syntax will help you the most in meeting your requirement.
Regards