Python Forum
Script to average 2 columns in .csv file, and print results to the file name.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script to average 2 columns in .csv file, and print results to the file name.
#1
Hi everyone, I'm running a test which outputs numerous .csv files (around 12). I need to average out the data in column G (7) and H (8). I'd then like to have the averages and the title of column 'G (7) CMAA' and column 'H (8) TAA' printed to show up at the respective .csv file name.

ex

Original .csv file output from my benchmark:
TestResult-Run1
TestResult-Run2
TestResult-Run3
etc..

What I would like for my script to do:
TestResult-Run1_CMAA-3.46_TAA-4.67.csv
TestResult-Run2_CMAA-3.89_TAA-3.49.csv
TestResult-Run3_CMAA-3.45_TAA-4.21.csv
etc..

Is this possible with a .bat script?
Reply
#2
What's this got to do with python?
Reply
#3
Sorry, I'm using a .bat file to generate the .csv files. But I would like to have python do the averaging and renaming of the files if it's possible.
Reply
#4
You can do this with python quite easily actually.
Not sure of the best way to go about it, perhaps load into a list so you can add columns.
This will work if rows are symmetrical.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pass arguments from bat file to pyhon script from application absolut 2 1,200 Jan-13-2025, 11:05 AM
Last Post: DeaD_EyE
  Best way to feed python script of a file absolut 6 1,201 Jan-11-2025, 07:03 AM
Last Post: Gribouillis
  How to write variable in a python file then import it in another python file? tatahuft 4 998 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  How to make it so whatever I input into a script gets outputted on a different file spermatozwario 4 1,219 Nov-24-2024, 12:58 PM
Last Post: deanhystad
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 1,124 Aug-26-2024, 10:14 PM
Last Post: shwfgd
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 1,085 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 6,677 Jun-17-2024, 12:26 AM
Last Post: AdamHensley
  Cannot get cmd to print Python file Schauster 11 3,303 May-16-2024, 04:40 PM
Last Post: xMaxrayx
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 12 4,515 Apr-12-2024, 11:51 AM
Last Post: deanhystad
  Create Choices from .ods file columns cspower 3 1,849 Dec-28-2023, 09:59 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020