Skip to main content
6 of 6
replaced http://stackoverflow.com/ with https://stackoverflow.com/

How to deal with persistent user sample or workload data?

Given a user provides a textual representation of data he has in a file and wants to load and process in the code provided with his question.

Those who want to try out the code of an answer don't have the user's workload data in their local storage, so they must produce it, which is a potentially error-prone, or even harmful (imagine there's a file called test.csv in the directory where their thesis-to-be resides) thing.

Or, if the data is inlined as a string in the answer, and treated such by e.g. C++'s std::stringstream or python3's io.StringIO (python2's StringIO.StringIO), the answer's code is, for beginners, not trivially convertible for a processing of physical files.

Is there a consensual or known best-practice way to deal with such persistence issues arising when answering a question?

EDIT

example

This

with open('mycsvfile.csv', 'w', newline='') as f:
    for row in journal_entries:
        for innerRow in row["journalEntryItems"]:
            writer= csv.DictWriter(f, innerRow.keys())
            writer.writerow(innerRow)

is the users code; the data sample he provides is the big .json he gives as a string in his question. Of course, the user has that file on disk, but those who want to try an answer's code, don't.

So it needs somehow to be made available in an answer with code that processes that data.

My question is about that somehow.