Created
October 24, 2017 22:42
-
-
Save DavidAntliff/ff631620838b2369d397266d59d49e98 to your computer and use it in GitHub Desktop.
Convert xxd hexdump to CSV file for spreadsheet import
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
# 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