Created
May 10, 2013 07:18
-
-
Save nipunbatra/5552904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_header_row(parameter_numbers, parameter_list): | |
'''This function creates the header for a CSV file. | |
The putput of this function should be appended to a CSV file upon creation | |
Input: | |
------ | |
Parameter List: A Python list consisting of strings corresponding to all electrical parameters provided by the smart meter | |
Parameter Numbers: A Python list corresponding to chosen parameters (to be logged to CSV) | |
Output: | |
------- | |
String of chosen parameters by name separated by comma and line terminated by newline | |
Example Usage | |
------------- | |
parameter_list=['timestamp','W','W1','V1','A1'] | |
parameter_numbers=[2,3] | |
header=create_header_row(parameter_number, parameter_list) | |
Then, | |
header= 'W1, | |
''' | |
out="" | |
for i in range(len(parameter_numbers)): | |
out+= parameter_numbers[parameter_numbers[i]] | |
return out+"\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment