Jump to content

Sum to values from a .csv and save it to a new .csv file


Recommended Posts

Hello,

I need to select a .csv file which has two integers seperated through a comma per line. I have to sume these to values and write it to a new .csv file with the two integers and as third position the result. I have a path selector and a read from spreadsheet and a write to spreadsheet element. But I do not know how to read the two values line per line and add those to values with the result in a new .csv file

 

For example:

input:

A,B
1,3
2,6
3,3

output:

A,B,C
1,3,4
2,6,8
3,3,6

I hope that somebody can help me.

 

Thanks for your help!
Greets from Austria,

Fabian

Link to comment

This isn't too difficult.  Once you have the read data as an array, go into an auto indexing for loop and process each row one at a time.  Then concatenate the sum to the end, and rebuild your 2D array before writing it again.  Attach the code you've tried.

Link to comment

So I got it done now. 

My problem is that the Headers of the input file (A,B) were converted to an (0,0) in the output file because I have set the read spreadsheet element to Integer. Is there a way to exclude the file header and write (A,B,C) to my output file?

 

2015 03 06   Read Write Spreadsheed   Headers

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.