Skip to content

Instantly share code, notes, and snippets.

@DavidAntliff
Created October 24, 2017 22:42
Show Gist options
  • Save DavidAntliff/ff631620838b2369d397266d59d49e98 to your computer and use it in GitHub Desktop.
Save DavidAntliff/ff631620838b2369d397266d59d49e98 to your computer and use it in GitHub Desktop.
Convert xxd hexdump to CSV file for spreadsheet import
# Assumes in_txt was generated by `xxd -g1 in.bin > in.txt`
import csv
with open(in_txt) as fin, open(out_csv, 'w') as fout:
o=csv.writer(fout, quotechar='"', quoting=csv.QUOTE_ALL)
for line in fin:
row = line.rstrip('\n').split(sep=' ', maxsplit=17)
# remove one leading space from last item
row[-1] = row[-1][1:]
o.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment