Skip to content

Instantly share code, notes, and snippets.

@jeremy-donson
Last active May 10, 2018 18:17
Show Gist options
  • Save jeremy-donson/31db7a69cb7ca1b9c01e4521f36f68d4 to your computer and use it in GitHub Desktop.
Save jeremy-donson/31db7a69cb7ca1b9c01e4521f36f68d4 to your computer and use it in GitHub Desktop.
$ pip3 install pyyaml
$ python3
>>> import yaml
>>> yaml.load("""
... - Hdf
... - Jgd
... - Kjhgd
... """)
['Hdf', 'Jgd', 'Kjhgd']
>>> dat = yaml.load("""
... - Hdf
... - Kjhgd
... - Jgd
... """)
>>> dat
['Hdf', 'Kjhgd', 'Jgd']
>>> dat = yaml.load("""
... List Name:
... - Hdf
... - Jgd
... - Kjhgd
... """)
>>> dat
{'List Name': ['Hdf', 'Jgd', 'Kjhgd']}
# write to file of dictname containing 1 list element per line
>>> for key in dat.keys():
... dictname = key;
... some_data = dat[dictname] => ?? ERRORS RIGHT NOW
>>> path = '/users/sammy/' + dictname + '.txt'
>>> test-file = open(path,'w')
>>> write2file = test-file.write()
# write one line for every list element
# close file
@jeremy-donson
Copy link
Author

Would like to add json and csv ascii text formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment