Reading a CSV file and adding in new rows if conditions are met. Adding in rows and columns in the csv file

The input file consists of

  • 5 columns named Id, name, hours, additional hours(10%), additional hours (20%)
  • if the values in the column - hours is other than 0, then in the output file under a column- type --> enter - regular and scale must be --> 100
  • if the value in the column – additional hours (10%) is other then 0, then in the output file under column- type --> enter - extra and scale must be --> 10
  • if the value in the column – additional hours (20%) is other then 0, then in the output file under column- type --> enter - extra and scale must be --> 20

The output file has 5 columns named

  • id
  • name
  • hours
  • type
  • scale

I’ll be attaching the images of both the csv files

  • input file

  • output file

Hi @ray_sha,

Can you attache the Sample CSV file to get the workaround for the same ?

Hey @Vivek.A.S
Thank you for replying!

Attaching the input file.
input.zip (195 Bytes)

Hey,
Is there any way??
I just want to have an information on how to add in new rows??
Does anyone have any clue about it?

Thanks in Advance!

Hi @ray_sha ,

Am got the Solution for that…Please run the Xaml File and let me know…

Main.xaml (7.5 KB) input.zip (195 Bytes)

Thank you,
A.S.VIVEK

1 Like

Hey @Vivek.A.S,
Thanks so much for replying!
The output given by your workflow has one one flaw, i.e. it doesn’t display the hours column as shown in the Output file.

The output file has “hours” column, which the above workflow doesn’t display!

Can you please rectify that?
Thanks in Advance!

Hi @ray_sha,

added the Hours column in the Write line …Please run the file given blow :
Main.xaml (7.7 KB)

1 Like

Hey @Vivek.A.S
Thanks for the reply!

Yeah! its working well for the write line. Can it also work for a CSV file?
I mean to say is, Can we get the output in a CSV file using write CSV?

Hey @ray_sha,

Create Data-table & Add the each row into the table with help of Built Data-table Activity , Add Data Row Activity & Write CSV Activity into the same For Loop.

Hey @Vivek.A.S

I’ve tried with the Add Data Row and it gives an error!
It won’t work in the loop!

Please feel free to go through the same and check it out!

Please let me know if you could achieve it!

Thanks in Advance!

hey @Vivek.A.S
Wanted some clarity on how your asking me to use Build-datatable activity in the loop.

Hey @ray_sha,
Run this File … you will get the OutPut.csv File & Please Mark as Solution
Main.xaml (19.7 KB)

1 Like

Hey @Vivek.A.S
I really appreciate your efforts.
The workflow is correct except there’s one additional empty row being included in the output file.
I’ll attach the image below.

Is there a way to rectify this?
Thanks in advance!

Hey @ray_sha,
empty row Removed.
Run this File and you will get the OutPut.csv File
Please Mark as Solution
Main.xaml (26.6 KB)

Thank & Regards,
A.S.VIVEK

1 Like

Hey @Vivek.A.S
The output, although not in the same order works well.
Thanks so much for the reply!

Thanks and Cheers!

Hey @ray_sha

Mark Solution on my Last Reply & Thanks

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