Skip to content

Instantly share code, notes, and snippets.

@steveway
Created June 14, 2022 09:45
Show Gist options
  • Select an option

  • Save steveway/5c984e55020e87da57fd1e49de75da90 to your computer and use it in GitHub Desktop.

Select an option

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
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