Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Created February 10, 2020 06:37
Show Gist options
  • Save Jongbhin/411ea4baa6bc0d725a282f538c1b16ca to your computer and use it in GitHub Desktop.
Save Jongbhin/411ea4baa6bc0d725a282f538c1b16ca to your computer and use it in GitHub Desktop.
[make dict for key value] #dict, #python, #pickle
with open(input_file) as ifd:
csv_reader = csv.reader(ifd, delimiter='\t', quoting=csv.QUOTE_NONE)
token_dict = {}
for counter, row in enumerate(csv_reader):
prd_no = row[0]
token_dict[prd_no] = row[1:]
with open(output_file, mode='w') as wfd:
pickle.dump(token_dict, wfd, protocol=pickle.HIGHEST_PROTOCOL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment