Created
June 14, 2022 09:45
-
-
Save steveway/5c984e55020e87da57fd1e49de75da90 to your computer and use it in GitHub Desktop.
This changes a SDM3000X saved .csv file so it can be opened via EasyDMM
This file contains hidden or 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
| import csv | |
| import argparse | |
| # this function will remove the first row and first column from the csv file | |
| def remove_first_row_and_first_column(input_file): | |
| temp_csv = [] | |
| with open(input_file, 'r') as f: | |
| reader = csv.reader(f) | |
| # remove the first row | |
| next(reader) | |
| # remove the first column | |
| for row in reader: | |
| row.pop(0) | |
| temp_csv.append(row) | |
| return temp_csv | |
| # Load file from argv and remove first row and first column | |
| if __name__ == '__main__': | |
| arg_parser = argparse.ArgumentParser(description='Remove first row and first column from csv file') | |
| arg_parser.add_argument('csv_file', help='csv file name') | |
| args = arg_parser.parse_args() | |
| csv_file = args.csv_file | |
| changed_file = remove_first_row_and_first_column(csv_file) | |
| # write the changed file to a new file | |
| with open('changed_file.csv', 'w', newline='') as f: | |
| writer = csv.writer(f) | |
| writer.writerows(changed_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment