Question

I have multiple data files that are named after what they contain. For example

machine-testM_pid-1234_key1-value1.log

There are keys and values separated by - and _. Is there a better syntax for this? Are there parsers that automatically read these kinds of files/filenames?

The idea here is that the filenames are human and machine readable.

Was it helpful?

Solution

There seems to be no standard file naming convention for key-values.

OTHER TIPS

8 years later...

I would suggest that you look into https://en.wikipedia.org/wiki/Query_string

They aren't pretty filenames, but you wouldn't have to re-invent the wheel with for example converting to dict/json since there are well-tested methods for parsing query strings, for example in the requests library.

There's a related question over at https://unix.stackexchange.com/questions/44153/good-style-practices-for-separators-in-file-or-directory-names as well that contains some useful information that contains some ideas for better visual separators (_-_ and ___) that might be better in this case

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top