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
  Cannot get cmd to print Python file Schauster 11 584 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 13 1,321 Apr-24-2024, 05:47 AM
Last Post: Bronjer
  Create Choices from .ods file columns cspower 3 718 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  file open "file not found error" shanoger 8 1,388 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Create csv file with 4 columns for process mining thomaskissas33 3 858 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  Updating sharepoint excel file odd results cubangt 1 968 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  Need to replace a string with a file (HTML file) tester_V 1 847 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can I change the uuid name of a file to his original file? MaddoxMB 2 1,047 Jul-17-2023, 10:15 PM
Last Post: Pedroski55
  Python Script to convert Json to CSV file chvsnarayana 8 2,714 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,200 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone

Forum Jump:

User Panel Messages

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