mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-30 18:27:53 +00:00 
			
		
		
		
	csv_convert: Fix whitespace
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		| @@ -23,14 +23,12 @@ if sys.version_info[0] != 3: | ||||
|     print("This script requires Python 3") | ||||
|     exit(1) | ||||
|  | ||||
|   | ||||
| sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) | ||||
|  | ||||
|  | ||||
| class CSVParcer(): | ||||
|     def __init__(self,csv_infile=None,csv_outfile=None): | ||||
| class CSVParcer: | ||||
|     def __init__(self, csv_infile=None, csv_outfile=None): | ||||
|  | ||||
|         idx = 0 | ||||
|         i_atten = -1 | ||||
|         i_rotation = -1 | ||||
|         i_rxbps = -1 | ||||
| @@ -46,34 +44,33 @@ class CSVParcer(): | ||||
|             x = line.split(",") | ||||
|             cni = 0 | ||||
|             for cn in x: | ||||
|                 if (cn == "Attenuation [dB]"): | ||||
|                 if cn == "Attenuation [dB]": | ||||
|                     i_atten = cni | ||||
|                 if (cn == "Position [Deg]"): | ||||
|                 if cn == "Position [Deg]": | ||||
|                     i_rotation = cni | ||||
|                 if (cn == "Throughput [Mbps]"): | ||||
|                 if cn == "Throughput [Mbps]": | ||||
|                     i_rxbps = cni | ||||
|                 if (cn == "Beacon RSSI [dBm]"): | ||||
|                 if cn == "Beacon RSSI [dBm]": | ||||
|                     i_beacon_rssi = cni | ||||
|                 if (cn == "Data RSSI [dBm]"): | ||||
|                 if cn == "Data RSSI [dBm]": | ||||
|                     i_data_rssi = cni | ||||
|                 cni += 1 | ||||
|  | ||||
|             # Write out out header for the new file. | ||||
|             fpo.write("Test Run,Position [Deg],Attenuation 1 [dB],Pal Stats Endpoint 1 Control Rssi [dBm],Pal Stats Endpoint 1 Data Rssi [dBm]\n") | ||||
|             fpo.write( | ||||
|                 "Test Run,Position [Deg],Attenuation 1 [dB],Pal Stats Endpoint 1 Control Rssi [dBm],Pal Stats Endpoint 1 Data Rssi [dBm]\n") | ||||
|  | ||||
|             # Read rest of the input lines, processing one at a time.  Covert the columns as | ||||
|             # needed, and write out new data to the output file. | ||||
|             line = fp.readline() | ||||
|  | ||||
|             bottom_half="Step Index,Position [Deg],Attenuation [dB],Traffic Pair 1 Throughput [Mbps]\n" | ||||
|             bottom_half = "Step Index,Position [Deg],Attenuation [dB],Traffic Pair 1 Throughput [Mbps]\n" | ||||
|  | ||||
|             test_run="1" | ||||
|             test_run = "1" | ||||
|  | ||||
|             step_i = 0 | ||||
|             while line: | ||||
|                 x = line.split(",") | ||||
|                 #print(x) | ||||
|                 #print([test_run, x[i_rotation], x[i_atten], x[i_beacon_rssi], x[i_data_rssi]]) | ||||
|                 fpo.write("%s,%s,%s,%s,%s" % (test_run, x[i_rotation], x[i_atten], x[i_beacon_rssi], x[i_data_rssi])) | ||||
|                 bottom_half += ("%s,%s,%s,%s\n" % (step_i, x[i_rotation], x[i_atten], x[i_rxbps])) | ||||
|                 line = fp.readline() | ||||
| @@ -83,37 +80,36 @@ class CSVParcer(): | ||||
|             fpo.write("\n\n# RvRvO Data\n\n") | ||||
|             fpo.write(bottom_half) | ||||
|  | ||||
| def main(): | ||||
|  | ||||
|     #debug_on = False | ||||
| def main(): | ||||
|     parser = argparse.ArgumentParser( | ||||
|         prog='csv_convert.py', | ||||
|         formatter_class=argparse.RawTextHelpFormatter, | ||||
|         epilog='''\ | ||||
|  Useful Information: | ||||
|             ''', | ||||
|          | ||||
|  | ||||
|         description=''' | ||||
| csv_convert.py:   | ||||
|     converts the candela brief csv into the data for specific customer, | ||||
|         ''') | ||||
|  | ||||
|     # for testing parser.add_argument('-i','--infile', help="input file of csv data", default='text-csv-0-candela.csv') | ||||
|     parser.add_argument('-i','--infile', help="input file of csv data", required=True) | ||||
|     parser.add_argument('-o','--outfile', help="output file in .csv format", default='outfile.csv') | ||||
|  | ||||
|     parser.add_argument('-i', '--infile', help="input file of csv data", required=True) | ||||
|     parser.add_argument('-o', '--outfile', help="output file in .csv format", default='outfile.csv') | ||||
|  | ||||
|     args = parser.parse_args() | ||||
|     csv_outfile_name = None | ||||
|     csv_infile_name = None | ||||
|  | ||||
|     if args.infile: | ||||
|         csv_infile_name = args.infile | ||||
|     if args.outfile: | ||||
|         csv_outfile_name = args.outfile | ||||
|  | ||||
|     print("infile: %s  outfile: %s"%(csv_infile_name, csv_outfile_name)) | ||||
|     print("infile: %s  outfile: %s" % (csv_infile_name, csv_outfile_name)) | ||||
|  | ||||
|     CSVParcer(csv_infile_name, csv_outfile_name) | ||||
|  | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matthew Stidham
					Matthew Stidham