From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sum Element of multiple csv files

Hello,

 

I am looking for some suggestions regarding summing the elements of multiple csv files and the the results in a new csv file. Any suggestion will be very helpful to me. 

 

Please feel free to ask for more details if you need to.

 

Kind regards,

Ketan Patel

0 Kudos
Message 1 of 8
(1,450 Views)

Well, you would iterate over all files while while keeping the running sum in shift registers, then write the result at the end.

 

Do you want to sum all elements, all rows, al columns, et.?

Are all files the same size?

 

so. many. questions.

0 Kudos
Message 2 of 8
(1,431 Views)

Hello Altenbach,

 

Yes, i would like to sum all the columns of each file. And yes, they are exactly the same length. They do however have labels for each column (name of the column, for example "Time"). I am not sure if that would create any error. 

 

Please feel free to ask as many questions you have 🙂

 

Regards,

Ketan

0 Kudos
Message 3 of 8
(1,422 Views)

well, you just need to deal with the header. No problem. Can you successfully read one file?

0 Kudos
Message 4 of 8
(1,410 Views)

Yes. The files are being read properly.

0 Kudos
Message 5 of 8
(1,402 Views)

Well, you are really feeding us information with an eye dropper!

 

It is still not clear at all what you mean by "summing the columns"...

 

  • (A) For each file, sum all elements of each column to form a single row? The output would have one row for each file.
  • (B) Just sum all files (In that case, summing rows, summing columns, or summing the entire 2D array, would be the same)!
  • something else?

 

Why can't you give an example?

 

File 1:

01 02 03

04 05 06

07 08 09

 

FIle 2:

01 02 03

04 05 06

07 08 09

 

Output according to one possible interpretation (B)

 

02 04 06

08 10 12

14 16 18

 

Is that what you want? Seems trivial to implement!

0 Kudos
Message 6 of 8
(1,383 Views)

It sounds like you need 2 Delimited Spreadsheet Files and 1 Add.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 8
(1,376 Views)
  • One "list folder" (using a suitable pattern)
  • One FOR loop, autoindexing over the files
  • One "build path"
  • One file read
  • One "add"
  • Special handling of first file.
  • One shift register to accumulate the sum
  • One File write after the loop.
  • plus maybe some handing of the headers (they can be left in place for the summing, ignored, and written back at the end). Not shown.

 

altenbach_0-1654872239821.png

 

 

0 Kudos
Message 8 of 8
(1,370 Views)