Skip to content

Instantly share code, notes, and snippets.

@sunflower2333
Last active July 25, 2024 11:30
Show Gist options
  • Select an option

  • Save sunflower2333/5ec2da74f14e303d4f2d2571219c8fd8 to your computer and use it in GitHub Desktop.

Select an option

Save sunflower2333/5ec2da74f14e303d4f2d2571219c8fd8 to your computer and use it in GitHub Desktop.
Transform EasyEDA ESP32 fanout csv output to C header
import csv
csv_file_path = 'Fan_Out_Netlabel_P1_2024-07-19.csv'
txt_file_path = 'o.txt'
with open(csv_file_path, encoding='utf-16le') as csvfile:
sr = csv.DictReader(csvfile, delimiter='\t', quotechar='|')
with open(txt_file_path, 'w', encoding='utf-16le') as txt_file:
for row in sr:
netname = row['netname']
pinName = row['pinName']
if netname != '' and \
pinName != '' and \
pinName != netname and \
pinName[:2]=='IO' and \
netname.count('+') == 0 and \
netname.count('-') == 0:
txt_file.write(f'#define {netname} GPIO_NUM_{pinName[2:]}\n')
print(f"成功将 {csv_file_path} 转换为 {txt_file_path}。")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment