Hack4Life Posted March 5, 2015 Report Posted March 5, 2015 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 Quote
hooovahh Posted March 5, 2015 Report Posted March 5, 2015 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. Quote
crossrulz Posted March 5, 2015 Report Posted March 5, 2015 Read Spreadsheet File and Write Spreadsheet File will get you half way there. Hooovahh told you what to do in the middle. Post back with some of your code if you run into issues. Quote
Hack4Life Posted March 5, 2015 Author Report Posted March 5, 2015 I am now here. I do not know how to split the values from the array to the sum operator.. Quote
Biometrology Posted March 6, 2015 Report Posted March 6, 2015 As hooovahh said, you need to use a for loop to index into the array. Inside the for loop you will have a 1D array which you need to index the first and second elements and add them. Concatenate that with the input 1 D array. Auto-indexing is your friend here. Quote
Hack4Life Posted March 6, 2015 Author Report Posted March 6, 2015 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? Quote
Jordan Kuehn Posted March 6, 2015 Report Posted March 6, 2015 You'll likely want to read it as a string and take care of converting between strings and numbers and back. Look for number/string conversion in the string palette. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.